Guild icon
swift-developers-japan
main / swiftbot-sandbox
Avatar
omochimetaru 02-Apr-18 05:50 AM
@swiftbot
print("hello channel")
Avatar
swiftbot BOT 02-Apr-18 05:50 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
hello channel
Avatar
Aryzae 02-Apr-18 05:53 AM
@swiftbot
let hoge = "hoge" dump(hoge)
Avatar
swiftbot BOT 02-Apr-18 05:53 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
- "hoge"
Avatar
Kishikawa Katsumi 02-Apr-18 06:17 AM
Targetの出力は不変だから消して良さそう。
Avatar
t.ae 02-Apr-18 06:21 AM
さっき @omochimetaru が書いてたトリプルクォートぶっ壊すので無限コンパイルされたりしないですか?
Avatar
omochimetaru 02-Apr-18 06:21 AM
@t.ae botからbotにメンションさせるってこと?
Avatar
t.ae 02-Apr-18 06:21 AM
はい。
Avatar
omochimetaru 02-Apr-18 06:21 AM
悪い事思いつくね。
Avatar
Biacco42 02-Apr-18 06:21 AM
たしかにできそう
Swift で Swift コードを出力してコンパイルとか…
Avatar
omochimetaru 02-Apr-18 06:22 AM
そうかそこは実行結果だから・・・
Avatar
Kishikawa Katsumi 02-Apr-18 06:23 AM
もし可能だとすると防ぐにはbot自身の発言かどうかを見たらいいのかな。
Avatar
omochimetaru 02-Apr-18 06:23 AM
とりあえずはそうですね。
Avatar
kateinoigakukun 02-Apr-18 06:24 AM
クワインだ
🔁 2
Avatar
omochimetaru 02-Apr-18 06:24 AM
同じようなボットがサーバーにもう一人いるときはキャッチボールできちゃうので
もうひと工夫必要そうですが。
Avatar
Biacco42 02-Apr-18 06:24 AM
相互呼び出し末尾再帰最適化っぽい
Avatar
rinsuki 02-Apr-18 08:16 AM
@swiftbot
print("\n``"+"`\n\n@swiftbot#4647 \n``"+"`swift\nprint(\"hello\")\n
") ```
Avatar
swiftbot BOT 02-Apr-18 08:16 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
@swiftbot#4647
print("hello")
```
Avatar
rinsuki 02-Apr-18 08:17 AM
@swiftbot
print("hoge\n``"+"`\n\n@swiftbot#4647 \n``"+"`swift\nprint(\"hello\")\n``"+"`")
Avatar
swiftbot BOT 02-Apr-18 08:17 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
hoge
@swiftbot#4647
print("hello")
```
🤔 1
Avatar
t.ae 02-Apr-18 08:25 AM
pre texts
@swiftbot
print("hello")
Avatar
swiftbot BOT 02-Apr-18 08:26 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
hello
Avatar
t.ae 02-Apr-18 08:28 AM
@swiftbot
print("hoge\n``"+"`\n\n<@4647> \n``"+"`swift\nprint(\"hello\")\n``"+"`")
Avatar
swiftbot BOT 02-Apr-18 08:28 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
hoge
@Unknown
print("hello")
```
Avatar
t.ae 02-Apr-18 08:31 AM
print("hoge\n`"+"\n\n<@!swiftbot> \n`"+"swift\nprint("hello")\n`"+"")
@swiftbot
print("hoge\n``"+"`\n\n<@!swiftbot> \n``"+"`swift\nprint(\"hello\")\n``"+"`")
@swiftbot
print("hoge\n``"+"`\n\n<@!swiftbot> \n``"+"`swift\nprint(\"hello\")\n``"+"`")
Avatar
swiftbot BOT 02-Apr-18 08:32 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
hoge
<@!swiftbot>
print("hello")
```
Avatar
Kishikawa Katsumi 02-Apr-18 09:13 AM
https://anidiots.guide/getting-started/your-basic-bot.html Bot同士でキャッチボールをしてしまうことの対策はちゃんと基本テクのところに書いてあった。 内容はやっぱりbotの発言かどうかをチェックするとのこと。 Botceptionっていうらしい?
あと私いま旅行中ですぐにSSHできないことが多いので、もし無限ループになってもすぐ止められないです。
Avatar
norio_nomura 02-Apr-18 09:26 AM
これ、バックエンドのAPIへ普通にcurlでアクセスできちゃうのですね。
Avatar
Kishikawa Katsumi 02-Apr-18 09:49 AM
https://swift-playground.kishikawakatsumi.com API もWeb UIも公開してます。
Avatar
koher 02-Apr-18 09:53 AM
@Kishikawa Katsumi そういえば https://swift-playground.kishikawakatsumi.com/ の初期コードの import Foundation がなくても良いように見えるのが気になってたんですが、これは Fundationimport できることを示すためとかでしょうか?
Avatar
Kishikawa Katsumi 02-Apr-18 09:54 AM
あまり深い意味はないんですけど、いういう意図もあります。あとは見栄えとか。
🙂 1
Avatar
koher 02-Apr-18 09:58 AM
もしかしたらコードを修正する過程の消し忘れかもとも思ったので、 Foundation の何かを使ってたらわかりやすいかもしれません。 round とかの関数だと使いやすそうです。
Avatar
Kishikawa Katsumi 02-Apr-18 10:04 AM
そうですね。ちょっと考えてみます。
Avatar
norio_nomura 02-Apr-18 10:07 AM
APIがvalidationなしにcommandをexecへ渡している様に見えるのですが、大丈夫ですか? https://github.com/kishikawakatsumi/swift-playground/blob/master/sandbox.js#L56 (edited)
Contribute to swift-playground development by creating an account on GitHub.
Avatar
Kishikawa Katsumi 02-Apr-18 10:15 AM
SwiftとSwiftcだけにチェックすべきですね。ありがとうこざいます。
どうもBot側のチェックと同じものを書く必要があると思ってたのですが、忘れてる気がしますね。
コマンド以外のパラメータについても。
Avatar
Kishikawa Katsumi 02-Apr-18 04:00 PM
#### Release note: - パラメータのバリデーションを改善しました。 Thanks @norio_nomura - Botへのメンションで、コードブロックがあればswiftの言語指定がなくても実行するようにしました。 - バージョン表記からTargetの行を取り除きました。 - Bot自身の投稿は無視するようにしました。 Thanks @t.ae
@swiftbot help
Avatar
swiftbot BOT 02-Apr-18 04:00 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 02-Apr-18 05:21 PM
@swiftbot
Avatar
swiftbot BOT 02-Apr-18 05:21 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
t.ae 03-Apr-18 12:22 AM
対応ありがとうございます。今の所メンション送る手段が見つかりませんでしたが……
@swiftbot
let 🐣 = "hiyoko" print("🐣 = \(🐣)")
😍 1
Avatar
swiftbot BOT 03-Apr-18 12:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
🐣 = hiyoko
Avatar
Kishikawa Katsumi 05-Apr-18 07:19 PM
@swiftbot versions
Avatar
swiftbot BOT 05-Apr-18 07:19 PM
Available Swift versions:
2018-04-04-a 2018-04-03-a 2018-04-02-a 2018-04-01-a 2018-03-31-a 4.1 4.0.3 3.1.1 3.0.2
Avatar
Kishikawa Katsumi 05-Apr-18 07:20 PM
とりあえず最新のスナップショットを追加したのと、ショートカットで--version=latest--version=stableというのを使えるようにしました。latestは最新のスナップショット、stableは最新のリリースバージョンが動きます。 (edited)
@swiftbot --version=latest
func fibonacci(number: Int) -> Int { if number <= 1 { return number } else { return fibonacci(number: number - 1) + fibonacci(number: number - 2) } } print(fibonacci(number: 10))
Avatar
swiftbot BOT 05-Apr-18 07:21 PM
Swift version 4.2-dev (LLVM 0d52728a8a, Clang b9ad4239d1, Swift a1eb1fe24c)
55
Avatar
omochimetaru 05-Apr-18 09:13 PM
@swiftbot
import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.executableURL = URL(fileURLWithPath: cmd[0]) let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) try! process.run() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/ls", "-al"]))
Avatar
swiftbot BOT 05-Apr-18 09:13 PM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:5:5: error: value of type 'Process' has no member 'executableURL' process.executableURL = URL(fileURLWithPath: cmd[0]) ^~~~~~~ ~~~~~~~~~~~~~ /usercode/main.swift:10:10: error: value of type 'Process' has no member 'run' try! process.run() ^~~~~~~ ~~~
Avatar
omochimetaru 05-Apr-18 09:15 PM
@swiftbot
import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/ls", "-al"]))
Avatar
swiftbot BOT 05-Apr-18 09:15 PM
Swift version 4.1 (swift-4.1-RELEASE)
total 76 drwxr-xr-x 1 root root 4096 Apr 5 21:15 . drwxr-xr-x 1 root root 4096 Apr 5 21:15 .. -rwxr-xr-x 1 root root 0 Apr 5 21:15 .dockerenv drwxr-xr-x 1 root root 4096 Apr 1 12:25 bin drwxr-xr-x 2 root root 4096 Apr 12 2016 boot drwxr-xr-x 5 root root 340 Apr 5 21:15 dev drwxr-xr-x 1 root root 4096 Apr 5 21:15 etc drwxr-xr-x 2 root root 4096 Apr 12 2016 home drwxr-xr-x 1 root root 4096 Apr 1 12:26 lib drwxr-xr-x 2 root root 4096 Feb 28 19:14 lib64 drwxr-xr-x 2 root root 4096 Feb 28 19:13 media drwxr-xr-x 2 root root 4096 Feb 28 19:13 mnt drwxr-xr-x 2 root root 4096 Feb 28 19:13 opt dr-xr-xr-x 130 root root 0 Apr 5 21:15 proc drwx------ 2 root root 4096 Feb 28 19:14 root drwxr-xr-x 1 root root 4096 Feb 28 19:14 run drwxr-xr-x 1 root root 4096 Apr 1 12:25 sbin drwxr-xr-x 2 root root 4096 Feb 28 19:13 srv dr-xr-xr-x 13 root root 0 Apr 5 21:15 sys drwxrwxrwt 1 root root 4096 Apr 5 21:15 tmp drwxrwxrwx 2 1000 1000 4096 Apr 5 21:15 usercode drwxr-xr-x 1 root root 4096 Mar 29 21:57 usr drwxr-xr-x 1 root root 4096 Feb 28 19:14 var
Avatar
omochimetaru 05-Apr-18 09:16 PM
@swiftbot
import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/cat", ".dockerenv"]))
Avatar
swiftbot BOT 05-Apr-18 09:16 PM
Swift version 4.1 (swift-4.1-RELEASE)
Avatar
omochimetaru 05-Apr-18 09:16 PM
@swiftbot
import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/ls", "-alR", "usercode"]))
Avatar
swiftbot BOT 05-Apr-18 09:16 PM
Swift version 4.1 (swift-4.1-RELEASE)
usercode: total 20 drwxrwxrwx 2 1000 1000 4096 Apr 5 21:16 . drwxr-xr-x 1 root root 4096 Apr 5 21:16 .. -rw-r--r-- 1 root root 0 Apr 5 21:16 errors -rw-r--r-- 1 root root 0 Apr 5 21:16 log -rw-rw-r-- 1 1000 1000 483 Apr 5 21:16 main.swift -rwxrwxr-x 1 1000 1000 164 Apr 5 21:16 script.sh -rw-r--r-- 1 root root 71 Apr 5 21:16 version
Avatar
omochimetaru 05-Apr-18 09:17 PM
@swiftbot
import Foundation func exec(_ cmd: [String]) -> String { let process = Process() process.launchPath = cmd[0] let pipe = Pipe() process.standardOutput = pipe process.arguments = Array(cmd[1...]) process.launch() let handle = pipe.fileHandleForReading let data = handle.readDataToEndOfFile() process.waitUntilExit() let str = String(data: data, encoding: .utf8) ?? "<binary>" return str } print(exec(["/bin/cat", "usercode/script.sh"]))
Avatar
swiftbot BOT 05-Apr-18 09:17 PM
Swift version 4.1 (swift-4.1-RELEASE)
#!/bin/bash swift --version > /usercode/version exec 1> "/usercode/log" exec 2> "/usercode/errors" $@ /usercode/main.swift mv /usercode/log /usercode/completed
Avatar
Kishikawa Katsumi 06-Apr-18 03:07 AM
Docker内の環境のリソースの使用を制限した方がいいかなという気もしますが、どうですかね? 今は時間制限も大して厳しくはないし、踏み台的な使い方がされてしまったりするのはありそうと思っています。
Avatar
koher 06-Apr-18 03:16 AM
ネットワークにはアクセスできないようにした方がいいかもしれませんね。
Avatar
Kishikawa Katsumi 06-Apr-18 03:25 AM
そうですね。それを制限しておけば外に迷惑をかけることはないはず?
Avatar
koher 06-Apr-18 03:29 AM
Docker 詳しくないですが、隔離されてるのでそのはずかと。あとは CPU とかメモリの使用量を制限しておけば、時間制限もあるし、何されても大体大丈夫そうな気がします。
Wandbox がどうしてるかという話が↓にありました。 https://qiita.com/melpon/items/e871abb8cd2b15558a53#%E7%89%9B%E8%88%8E
Wandbox は、オンラインでコンパイルや実行が試せるサービスで、主に私(@melponn) と [@kikairoya](...
Avatar
Kishikawa Katsumi 06-Apr-18 04:28 AM
週末ちょっと対策しましょ
Avatar
Kishikawa Katsumi 06-Apr-18 05:59 AM
@swiftbot
import Foundation let semaphore = DispatchSemaphore(value: 0) let url = URL(string: "http://httpbin.org/get")! let task = URLSession.shared.dataTask(with: url) { (data, response, error) in defer{ semaphore.signal() } if let error = error { print(error) return } print(response!.url!) print(String(data: data!, encoding: .utf8)!) }; task.resume() semaphore.wait()
Avatar
swiftbot BOT 06-Apr-18 05:59 AM
Swift version 4.1 (swift-4.1-RELEASE)
http://httpbin.org/get { "args": {}, "headers": { "Accept": "*/*", "Accept-Encoding": "deflate, gzip", "Accept-Language": "en", "Connection": "close", "Host": "httpbin.org", "User-Agent": "swift (unknown version) curl/7.47.0" }, "origin": "138.68.23.220", "url": "http://httpbin.org/get" }
Avatar
Kishikawa Katsumi 06-Apr-18 05:59 AM
普通にネットワークアクセスできるんだな。。。
😱 3
Avatar
omochimetaru 06-Apr-18 09:47 AM
@swiftbot
print(“hello iPad”)
Avatar
swiftbot BOT 06-Apr-18 09:47 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:1:20: error: unicode curly quote found, replace with '"' print(“hello iPad”) /usercode/main.swift:1:7: error: unicode curly quote found, replace with '"' print(“hello iPad”)
Avatar
omochimetaru 06-Apr-18 09:47 AM
ああああ
@swiftbot
print("hello from iPad")
Avatar
swiftbot BOT 06-Apr-18 09:49 AM
Swift version 4.1 (swift-4.1-RELEASE)
hello from iPad
Avatar
tarunon 06-Apr-18 02:31 PM
スマートじゃない引用符ワロタ
Avatar
norio_nomura 06-Apr-18 03:18 PM
@swiftbot --options="format"
if true { print("hello") }
Avatar
swiftbot BOT 06-Apr-18 03:18 PM
Swift version 4.1 (swift-4.1-RELEASE)
if true { print("hello") }
Avatar
Kishikawa Katsumi 07-Apr-18 01:33 AM
@swiftbot
import Foundation let semaphore = DispatchSemaphore(value: 0) let url = URL(string: "http://httpbin.org/get")! let task = URLSession.shared.dataTask(with: url) { (data, response, error) in defer{ semaphore.signal() } if let error = error { print(error) return } print(response!.url!) print(String(data: data!, encoding: .utf8)!) }; task.resume() semaphore.wait()
Avatar
swiftbot BOT 07-Apr-18 01:33 AM
Swift version 4.1 (swift-4.1-RELEASE)
URLError(_nsError: Could not resolve host: httpbin.org)
Avatar
Kishikawa Katsumi 07-Apr-18 01:33 AM
とりあえずネットワークを無効にしてみた。
😀 1
Avatar
taketo1024 08-Apr-18 01:56 AM
@swiftbot
import SwiftyMath
Avatar
swiftbot BOT 08-Apr-18 01:56 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
😅 1
Avatar
Kishikawa Katsumi 08-Apr-18 01:57 AM
作業中です。
Avatar
taketo1024 08-Apr-18 02:00 AM
すいません、つい気持ちが先走ってw
Avatar
Kishikawa Katsumi 08-Apr-18 02:12 AM
@taketo1024 現状のコードだとUbuntuではarc4randomがないのでビルドできなくて(arc4randomはBSDならある) https://github.com/kishikawakatsumi/SwiftyMath/commit/c5d8dc1dd1da145459477df1d2a9a60327da6c38 のようにlibbsdに依存するか、arc4randomじゃないrandom生成器を使うかのどちらかの対応が必要です。暗号的乱数でもなさそうなので依存パッケージを増やすほどでもないかなという気もしますが、ここのRandomってどういう性質のものですかね?
Avatar
taketo1024 08-Apr-18 02:15 AM
なるほど!
テスト用に例えばランダムな行列を生成するのとかに使ってました。
ランダムが arc4random でないといけない必要性は特にありません。
Avatar
Kishikawa Katsumi 08-Apr-18 02:22 AM
とりあえず暫定版として、
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath typealias F5 = IntegerQuotientRing<_5> F5.printAddTable() F5.printMulTable()
Avatar
swiftbot BOT 08-Apr-18 02:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
+ | 0 1 2 3 4 -------------------------- 0 | 0 1 2 3 4 1 | 1 2 3 4 0 2 | 2 3 4 0 1 3 | 3 4 0 1 2 4 | 4 0 1 2 3 * | 0 1 2 3 4 -------------------------- 0 | 0 0 0 0 0 1 | 0 1 2 3 4 2 | 0 2 4 1 3 3 | 0 3 1 4 2 4 | 0 4 3 2 1
Avatar
taketo1024 08-Apr-18 02:23 AM
キタコレ! 🤩
Avatar
Kishikawa Katsumi 08-Apr-18 02:23 AM
@taketo1024 あとで使い勝手はもうちょっと考えますけど、とりあえず^のように特殊なSwiftバージョンとオプションを指定して使ってみてください。そもそもやりたいことはこれで満たせるのかとか知りたいです。
Avatar
taketo1024 08-Apr-18 02:24 AM
@swiftbot
import SwiftyTopology
Avatar
swiftbot BOT 08-Apr-18 02:24 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:1:8: error: no such module 'SwiftyTopology' import SwiftyTopology ^
Avatar
taketo1024 08-Apr-18 02:24 AM
あ、なるほど
今出先なので後で試してみます!
Avatar
Kishikawa Katsumi 08-Apr-18 02:25 AM
ここでインポートしてるのはdSwiftyMathなのでSwiftyTopologyは入ってるんじゃないかな。。。?
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath let a = 𝐐(4, 5) // 4/5 let b = 𝐐(3, 2) // 3/2 print(a + b) // 23/10
Avatar
swiftbot BOT 08-Apr-18 02:26 AM
Swift version 4.1 (swift-4.1-RELEASE)
23/10
Avatar
Kishikawa Katsumi 08-Apr-18 02:27 AM
Chatbotで使えるということはWebでも使えるんですけど今のところWebにはSwiftのバージョンを切り替える方法やオプションを渡す手がないですね。。。
テスト用に例えばランダムな行列を生成するのとかに使ってました。
ランダムが arc4random でないといけない必要性は特にありません。 なるほど。じゃあarc4randomとrandを切り替えるような実装の方が簡単でいいかな?
うーん、SwiftyTopologyは含まれてないっぽいですね。。。
Avatar
taketo1024 08-Apr-18 02:36 AM
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) print(S.detailDescription)
Avatar
swiftbot BOT 08-Apr-18 02:36 AM
Swift version 4.1 (swift-4.1-RELEASE)
S^3 { 0: v₁, v₂, v₃, v₄, v₀ 1: (v₁, v₂), (v₁, v₃), (v₂, v₃), (v₁, v₄), (v₂, v₄), (v₃, v₄), (v₀, v₂), (v₀, v₃), (v₀, v₄), (v₀, v₁) 2: (v₁, v₂, v₃), (v₁, v₂, v₄), (v₁, v₃, v₄), (v₂, v₃, v₄), (v₀, v₂, v₃), (v₀, v₂, v₄), (v₀, v₃, v₄), (v₀, v₁, v₃), (v₀, v₁, v₄), (v₀, v₁, v₂) 3: (v₁, v₂, v₃, v₄), (v₀, v₂, v₃, v₄), (v₀, v₁, v₃, v₄), (v₀, v₁, v₂, v₄), (v₀, v₁, v₂, v₃) }
Avatar
Kishikawa Katsumi 08-Apr-18 02:36 AM
あ、できた。
Avatar
taketo1024 08-Apr-18 02:36 AM
大丈夫です!
Avatar
Kishikawa Katsumi 08-Apr-18 02:36 AM
なるほどー
Avatar
taketo1024 08-Apr-18 02:37 AM
@swiftbot --version=4.1a --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription)
Avatar
swiftbot BOT 08-Apr-18 02:37 AM
Swift version 4.1 (swift-4.1-RELEASE)
H(S^3; 𝐙) = { 0 : 𝐙, [v₄], 1 : 0, [], 2 : 0, [], 3 : 𝐙, [-1(v₀, v₁, v₃, v₄) + -1(v₁, v₂, v₃, v₄) + (v₀, v₁, v₂, v₄) + -1(v₀, v₁, v₂, v₃) + (v₀, v₂, v₃, v₄)] }
Avatar
taketo1024 08-Apr-18 02:37 AM
素晴らしい😆 chat bot で homology が計算できる時代💖
Avatar
Kishikawa Katsumi 08-Apr-18 02:38 AM
(何が素晴らしいのかさっぱりわかりませんが🙇🏻😜)めっちゃ便利ですね!
😂 1
ごめんなさい。これを機会に数学を教えてください。
Avatar
taketo1024 08-Apr-18 02:39 AM
是非!
いずれ SwiftyMath を使って Swifter 向けの数学講座をやりたいです😆
Avatar
Kishikawa Katsumi 08-Apr-18 02:41 AM
いいですね。 とりあえずいきなりトポロジーに行くのは無理そうですね。前提となる知識がもっと必要そう。
Avatar
taketo1024 08-Apr-18 02:42 AM
線型代数だけで行けます!(線型代数の導入も SwiftyMath でできる予定👍
Avatar
Kishikawa Katsumi 08-Apr-18 02:44 AM
まず線形代数なんですね。私は数III数Cを学んでないのでそこからですね。
Avatar
taketo1024 08-Apr-18 02:46 AM
せっかく Swift で作ってるので、ベクトルを指で動かしたりしてインタラクティブに学べるようなものにしたい💪 (edited)
😍 1
Avatar
Kishikawa Katsumi 08-Apr-18 05:00 AM
@swiftbot
import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription)
Avatar
swiftbot BOT 08-Apr-18 05:00 AM
Swift version 4.1 (swift-4.1-RELEASE)
H(S^3; 𝐙) = { 0 : 𝐙, [v₄], 1 : 0, [], 2 : 0, [], 3 : 𝐙, [-1(v₁, v₂, v₃, v₄) + -1(v₀, v₁, v₃, v₄) + (v₀, v₁, v₂, v₄) + (v₀, v₂, v₃, v₄) + -1(v₀, v₁, v₂, v₃)] }
Avatar
taketo1024 08-Apr-18 05:01 AM
お!
Avatar
Kishikawa Katsumi 08-Apr-18 05:01 AM
@taketo1024 デフォルトでSwiftyMathをリンクするようにしました。importだけ書けばOKです。
他の人には影響ないと思いますが、もし何か問題を見つけたら教えてください。 デフォルトのオプションを与えているという仕組みなので、--optionsを別の何かで上書きすると以前と同じバニラのSwift環境が使えます。 SwiftyMathをリンクしているのは今の所stable (== 4.1)のみです。
Avatar
Kishikawa Katsumi 08-Apr-18 05:18 AM
上で私間違ったこと書いてて、arc4randomは明示的なシードの初期化がいらないってだけで暗号論的に安全な乱数を返すわけではないですね😅
Avatar
taketo1024 09-Apr-18 06:01 AM
rand() 使おうとしたら 'rand()' is unavailable in Swift: Use arc4random ってでますね…(それで arc4random にしたんでした) (edited)
Avatar
omochimetaru 09-Apr-18 06:04 AM
@Kishikawa Katsumi arc4randomは暗号論的安全じゃないですか? man arc4random
DESCRIPTION These functions use a cryptographic pseudo-random number generator to generate high quality random bytes very quickly.
Avatar
taketo1024 09-Apr-18 06:06 AM
drand48() は使えた。これなら Ubuntu でもビルドできるんですかね?
Avatar
omochimetaru 09-Apr-18 06:06 AM
https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator よく見るのは CSPRNG ですけど CPRNGとも言うようです
A cryptographically secure pseudo-random number generator (CSPRNG) or cryptographic pseudo-random number generator (CPRNG) is a pseudo-random number generator (PRNG) with properties that make it suitable for use in cryptography. Most cryptographi...
Avatar
Kishikawa Katsumi 09-Apr-18 06:06 AM
ほんとだ。arc4randomってAppleのRC4実装って意味だったのか。
😀 1
@taketo1024 やってみてください。swiftbotで実行できればOK
Avatar
taketo1024 09-Apr-18 06:07 AM
あ、そっかw
@swiftbot
print(drand48())
Avatar
swiftbot BOT 09-Apr-18 06:07 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:1:7: error: use of unresolved identifier 'drand48' print(drand48()) ^~~~~~~
Avatar
taketo1024 09-Apr-18 06:07 AM
damepo
Avatar
Kishikawa Katsumi 09-Apr-18 06:08 AM
どうかな。importが足りないとかの可能性。
Avatar
taketo1024 09-Apr-18 06:08 AM
@swiftbot
import Foundation print(drand48())
Avatar
swiftbot BOT 09-Apr-18 06:08 AM
Swift version 4.1 (swift-4.1-RELEASE)
3.90798504668055e-14
Avatar
taketo1024 09-Apr-18 06:08 AM
お!
いけますね👍
Avatar
Kishikawa Katsumi 09-Apr-18 06:09 AM
@swiftbot
import Glibc print(drand48())
Avatar
swiftbot BOT 09-Apr-18 06:09 AM
Swift version 4.1 (swift-4.1-RELEASE)
3.90798504668055e-14
Avatar
omochimetaru 09-Apr-18 06:10 AM
HISTORY The original version of this random number generator used the RC4 (also known as ARC4) algorithm. In OS X 10.12 it was replaced with the NIST-approved AES cipher, and it may be replaced again in the future as cryptographic techniques advance. A good mnemonic is ``A Replacement Call for Random''.
訳すと RC4(ARC4とも言う)アルゴリズムの実装だけど OS10.12で AESに変わったし、後にまた変わるから、 A Replacement Call For Random の略として覚えると良いよ
(edited)
😀 1
Avatar
Kishikawa Katsumi 09-Apr-18 06:10 AM
drandはシードの初期化が必要かな。
A Replacement Call For Random
Hahaha
(edited)
Avatar
taketo1024 09-Apr-18 06:17 AM
@swiftbot
import Foundation srand48(time(nil)) print(drand48())
Avatar
swiftbot BOT 09-Apr-18 06:17 AM
Swift version 4.1 (swift-4.1-RELEASE)
0.918770220204355
Avatar
taketo1024 09-Apr-18 06:17 AM
@swiftbot
import Foundation srand48(time(nil)) print(drand48())
Avatar
swiftbot BOT 09-Apr-18 06:17 AM
Swift version 4.1 (swift-4.1-RELEASE)
0.272781763532297
Avatar
taketo1024 09-Apr-18 06:17 AM
これでいけそうですかね👍
初期化を呼び出すタイミングはこんなんでいいんでしょうかw
private var randInit = false private func rand() -> Double { if !randInit { srand48(time(nil)) randInit = true } return drand48() }
Avatar
Kishikawa Katsumi 09-Apr-18 06:18 AM
メソッド名を後付けで別の解釈にするというのはおもしろいな。
Avatar
omochimetaru 09-Apr-18 06:19 AM
たしかにw 互換性の取り方としては珍しいw
Avatar
Kishikawa Katsumi 09-Apr-18 06:19 AM
めっちゃ実装によったメソッド名をつけたのがそもそもアレなんだけどrandom()は名前空間自体がもういっぱいいっぱいなのでしょうがないんでしょう。
Avatar
omochimetaru 09-Apr-18 06:20 AM
@taketo1024 逆にMacだと動かなそうなので、arc4randomとそれをOSで切り替えるラッパーを作ると良いです。 (edited)
😯 1
Avatar
d_date 09-Apr-18 06:21 AM
いわゆる語呂合わせか、面白い
Avatar
taketo1024 09-Apr-18 06:22 AM
@omochimetaru まじですか?手元ではコンパイル通ってるんですが。
Avatar
omochimetaru 09-Apr-18 06:22 AM
あ、ほんとですか、じゃあ大丈夫です。
Avatar
taketo1024 09-Apr-18 06:39 AM
@Kishikawa Katsumi arc4random 未使用版 push しました ✋ 時間のあるときにでも更新お願いします 🙏
👌 1
Avatar
hiragram 09-Apr-18 07:39 AM
@swiftbot
extension Never: ExpressibleByNilLiteral { public init(nilLiteral: ()) { self = unsafeBitCast((), to: Never.self) } } let a: Never = nil print(a)
Avatar
swiftbot BOT 09-Apr-18 07:39 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:9:7: warning: will never be executed print(a) ^ /usercode/main.swift:7:16: note: a call to a never-returning function let a: Never = nil ^ /usercode/main.swift:2:12: warning: will never be executed public init(nilLiteral: ()) { ^ /usercode/main.swift:2:12: note: a call to a never-returning function public init(nilLiteral: ()) { ^ Segmentation fault (core dumped)
Avatar
Kishikawa Katsumi 09-Apr-18 07:40 AM
Segmentation fault!
Avatar
tarunon 09-Apr-18 07:41 AM
やべえ
Avatar
hiragram 09-Apr-18 07:41 AM
Xcodeのplaygroundだとこうなので
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) * frame #0: 0x00007fffaba7aa9b libobjc.A.dylib`_objc_msgSend_uncached + 11 frame #1: 0x00007fff9865d231 Foundation`-[NSPlaceholderString initWithString:] + 107 frame #2: 0x00000001036ca007 PlaygroundLogger`function signature specialization <Arg[0] = Dead> of static PlaygroundLogger.LoggingPolicyStack.get() -> PlaygroundLogger.LoggingPolicyStack + 151 frame #3: 0x00000001036c3f22 PlaygroundLogger`function signature specialization <Arg[1] = Owned To Guaranteed and Exploded> of playground_log_hidden + 98 frame #4: 0x00000001036c365b PlaygroundLogger`playground_log_hidden + 27 frame #5: 0x00000001041db0a7 $__lldb_expr158`Never.init(nilLiteral=() @ scalar) at MyPlayground.playground:4
libobjcなのでlinux環境だとどうなるんかなーと
Avatar
omochimetaru 09-Apr-18 07:41 AM
まあunsafeBitCast使えば別にどんな死でも起きるでしょ (edited)
CatなDogとか作り放題だし
Avatar
Kishikawa Katsumi 09-Apr-18 07:42 AM
コンパイルだけだと起こらないから実行時か。
Avatar
omochimetaru 09-Apr-18 07:42 AM
Never作っちゃったら、いろんな前提が壊れるから終わる
Avatar
hiragram 09-Apr-18 07:42 AM
@swiftbot
extension Never: ExpressibleByNilLiteral { public init(nilLiteral: ()) { self = unsafeBitCast((), to: Never.self) print("わいわい") } } let a: Never = nil print(a)
Avatar
swiftbot BOT 09-Apr-18 07:42 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:10:7: warning: will never be executed print(a) ^ /usercode/main.swift:8:16: note: a call to a never-returning function let a: Never = nil ^ /usercode/main.swift:2:12: warning: will never be executed public init(nilLiteral: ()) { ^ /usercode/main.swift:2:12: note: a call to a never-returning function public init(nilLiteral: ()) { ^ /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fa0085a4390] /usr/lib/swift/linux/libswiftCore.so(swift_conformsToProtocol+0x30)[0x7fa004780730] /usr/lib/swift/linux/libswiftCore.so(+0x39c05f)[0x7fa00477205f] /usr/lib/swift/linux/libswiftCore.so(+0x39b82d)[0x7fa00477182d] /usr/lib/swift/linux/libswiftCore.so(+0x2e518a)[0x7fa0046bb18a] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -I /usr/lib/swift/clang/include/ -I /vendor/SwiftyMath/.build/release/ -I /vendor/swift-package-libbsd/ -module-name main -ldSwiftyMath Segmentation fault (core dumped)
Avatar
hiragram 09-Apr-18 07:42 AM
なんか変わったぞ
Xcodeだと"わいわい"出てくるぞ
わいわい Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) * frame #0: 0x00007fffaba7c64e libobjc.A.dylib`_object_remove_assocations + 24 frame #1: 0x00007fffaba7c603 libobjc.A.dylib`objc_destructInstance + 105 frame #2: 0x000000011048e398 libswiftCore.dylib`swift_deallocClassInstance + 24 frame #3: 0x000000011048e2f0 libswiftCore.dylib`_swift_release_dealloc + 16 frame #4: 0x000000010e437012 PlaygroundLogger`function signature specialization <Arg[0] = Dead> of static PlaygroundLogger.LoggingPolicyStack.get() -> PlaygroundLogger.LoggingPolicyStack + 162 frame #5: 0x000000010e430f22 PlaygroundLogger`function signature specialization <Arg[1] = Owned To Guaranteed and Exploded> of playground_log_hidden + 98 frame #6: 0x000000010e43065b PlaygroundLogger`playground_log_hidden + 27 frame #7: 0x000000010e4680af $__lldb_expr160`Never.init(nilLiteral=() @ scalar) at MyPlayground.playground:4
Avatar
tarunon 09-Apr-18 07:46 AM
Unsafe bit castでDogをCatに改造すると
結構面白いことになる
Avatar
omochimetaru 09-Apr-18 07:53 AM
同じシグネチャのメソッドならそのまま呼び出せるみたいなね。
Avatar
tarunon 09-Apr-18 07:55 AM
var foo: Foo { return x } と func foo() -> Foo { return x }の扱いが、前者はフィールドとして定義されているのでunsafeBitCastしても同じものが呼ばれるが、後者は実質的には第一引数にselfを与えるstatic funcなのでunsafeBitCastで違うものが呼ばれる、とか。
Avatar
tarunon 09-Apr-18 08:25 AM
var foo: Foo { return x } じゃなくて let foo: Foo = x だった。
@swiftbot
struct Cat { let face: String = "😺" func bark() -> String { return "にゃーん" } } struct Dog { let face: String = "🐶" func bark() -> String { return "わんわん" } } let cat = unsafeBitCast(Dog(), to: Cat.self) print(cat.face) print(cat.bark())
Avatar
swiftbot BOT 09-Apr-18 08:25 AM
Swift version 4.1 (swift-4.1-RELEASE)
🐶 にゃーん
Avatar
omochimetaru 09-Apr-18 08:27 AM
@swiftbot
struct Cat { let face: String = "😺" func bark() -> String { return "\(face): にゃーん" } } struct Dog { let face: String = "🐶" func bark() -> String { return "\(face): わんわん" } } let cat = unsafeBitCast(Dog(), to: Cat.self) print(cat.face) print(cat.bark())
Avatar
swiftbot BOT 09-Apr-18 08:28 AM
Swift version 4.1 (swift-4.1-RELEASE)
🐶 🐶: にゃーん
Avatar
omochimetaru 09-Apr-18 08:28 AM
@swiftbot
struct Cat { let face: String = "😺" func bark() -> String { return "\(face): にゃーん" } } struct Dog { let face: String = "🐶" func bark() -> String { return "\(face): わんわん" } } let cat = unsafeBitCast(Dog(), to: Cat.self) print(cat.bark())
Avatar
swiftbot BOT 09-Apr-18 08:28 AM
Swift version 4.1 (swift-4.1-RELEASE)
🐶: にゃーん
Avatar
omochimetaru 09-Apr-18 08:28 AM
ははは
Avatar
Kishikawa Katsumi 09-Apr-18 08:28 AM
これは正しい挙動でいいんですよね?
Avatar
tarunon 09-Apr-18 08:29 AM
letで定数として定義しても、値に対してのプロパティなら、ちゃんと値に対してメモリ確保されてるのがわかる。正しいと思います。
Avatar
omochimetaru 09-Apr-18 08:30 AM
structのメソッド呼び出しは非仮想だから cat. の型に関係なく固定でcat用のメソッドが呼ばれてますね (edited)
unsafeBitCastの使用自体が正しくないから、その時点で何も正しくないともいえるし、その行を正しいとみなすなら何も壊れてない
Avatar
tarunon 09-Apr-18 08:31 AM
そもそもStructのメソッド呼び出しは動的ディスパッチにすると無駄すぎなので
あとはletでちゃんとメモリ確保されてるなーというのがわかるのその2
@swiftbot
struct One { let one = 1 } struct OneTwoThree { let one = 1 let two = 2 let three = 3 } print(MemoryLayout.size(ofValue: One())) print(MemoryLayout.size(ofValue: OneTwoThree()))
Avatar
swiftbot BOT 09-Apr-18 08:31 AM
Swift version 4.1 (swift-4.1-RELEASE)
8 24
Avatar
omochimetaru 09-Apr-18 08:32 AM
たしかに意味的にはオブジェクト内部に値持つ必要はないよな
Avatar
tarunon 09-Apr-18 08:33 AM
そうそう、ちょっと気になった。持たないといけない理由あるのかなーとか
ABI互換とかはどうなんだろう
Avatar
omochimetaru 09-Apr-18 08:34 AM
あー
リザイレンスでは
letでもgetterになっていて
ABI互換を取りたいかも?
あ、でもstructだとそもそもサイズが変わっちゃって無理か。
Avatar
tarunon 09-Apr-18 08:34 AM
うん、気になったのはletがちゃんとpropertyとして成立していて
でもこれCodableからは除去されるんだよね
だからその辺上手いことやってるのはどこに仕掛けがあるんやろか、って思った
Avatar
omochimetaru 09-Apr-18 08:35 AM
Codableはまあゴリゴリ書かれてるからletは除外してるんじゃないか
そもそもそのケースってinitから代入もできないから
CodableでDecodeしようがなくない
あれ、できるっけ
Avatar
tarunon 09-Apr-18 08:36 AM
initで定義されるletとフィールドに直埋めのletがCodableでは違う扱いになってるのが (edited)
しかしメモリレイアウトは同じだった、っていう点がおもろい
Avatar
omochimetaru 09-Apr-18 08:37 AM
@swiftbot
struct Cat { let age: Int = 3 init() { self.age = 5 } } print(Cat())
Avatar
swiftbot BOT 09-Apr-18 08:37 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:5:18: error: immutable value 'self.age' may only be initialized once self.age = 5 ^ /usercode/main.swift:2:9: note: initial value already provided in 'let' declaration let age: Int = 3 ^ /usercode/main.swift:2:5: note: change 'let' to 'var' to make it mutable let age: Int = 3 ^~~ var
Avatar
omochimetaru 09-Apr-18 08:40 AM
letで書いておけば、あとでvarになったときにも
メモリレイアウト互換性が保たれるっていう
ABI仕様があれば、実用性もある仕様になると思う
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
Avatar
tarunon 09-Apr-18 08:41 AM
ふむふむ
Avatar
omochimetaru 09-Apr-18 08:41 AM
いまはまだ
特に確定してない
Define layout algorithms for structs
Avatar
norio_nomura 10-Apr-18 04:56 AM
docker-compose使ってローカルのDockerで岸川さんのswift-playgroundを実行できる様になった。
Avatar
Kishikawa Katsumi 10-Apr-18 04:56 AM
@norio_nomura Docker in dockerになります?
Avatar
norio_nomura 10-Apr-18 04:57 AM
イメージの重複が嫌だったのでホストとソケット共有です。
Avatar
Kishikawa Katsumi 10-Apr-18 04:58 AM
Macから、ホストとなるDocker(A)でLinuxを動かして、その中でリクエストごとのDocker(B)を起動して、AのソケットをBと共有、ですか? (edited)
Avatar
norio_nomura 10-Apr-18 05:00 AM
docker-compose.yml
version: '3' services: playground: build: . environment: HOST_PWD: ${PWD} ports: - "80:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock - .:/playground command: ["sh", "-c", "npm install && npm start"]
Dockerfile
FROM docker:latest RUN apk --update add bash nodejs && rm -rf /var/cache/apk/* WORKDIR /playground
😁 1
githubへ上げた方が早いね。
Avatar
Kishikawa Katsumi 10-Apr-18 05:03 AM
前に似たようなことをしようとした時、Playgroundが都度起動するDockerのoutput(/usercode/completeとerrors)がうまく外のDockerから取れなかったんですけど、そこうまくいってます? (edited)
Avatar
norio_nomura 10-Apr-18 05:04 AM
環境変数HOST_PWDにホストのディレクトリを持たせ、それをsandboxに渡してます。
run.shの起動は/playground/run.sh 30 -v /Users/norio/github/swift-playground/temp/6e4fd5db976425e7d17a:/usercode -v /playground/vendor:/vendor:ro norionomura/swiftlint:swift-4.1 sh /usercode/script.sh swiftな感じに。
docker:dindにすればホストのパスは要らないけど、docker:dindだとホストの/var/lib/docker/volumesにデータが溜まっていくらしく、それを避けたかった。
Avatar
Kishikawa Katsumi 10-Apr-18 05:12 AM
なるほど。Docker comopseで全部まとめてセットアップできると便利ですね。これをベースにNginxとSSLもまとめると、GitHubのPRベースで誰でもSwiftbotに自分の好きなフレームワークを追加したりできるかな?
Avatar
norio_nomura 10-Apr-18 05:20 AM
最初はDinDのコンテナもあったのですが、結局HOST_PWDの自動取得くらいにしかdocker-composeを活かせてないですね。
Avatar
norio_nomura 10-Apr-18 05:41 AM
とりあえず、optionsexecへ文字列結合されて渡されてるところが心配。
options="; docker run -v /:/host_root ubuntu cat /host_root/etc/passwd;"とかすると、そのまま実行されてしまわないかな?
Avatar
Kishikawa Katsumi 10-Apr-18 05:46 AM
optionsは検討の余地ありですね。swiftcと任意のオプション、を使えると便利かなと思ったけど、今までで使われてるのはバージョン指定くらいだから任意のオプションはナシにしてもいいかも。
Avatar
norio_nomura 10-Apr-18 10:13 AM
一応使う手順を書いておくと
docker pull norionomura/swiftlint:swift-4.1 # 利用するswiftイメージをあらかじめpull git clone https://github.com/norio-nomura/swift-playground.git -b docker-compose cd swift-playground docker-compose up
してブラウザで http://localhost を開く。
Avatar
hiragram 11-Apr-18 04:13 AM
@swiftbot
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① guard 1 == 0 else { hoge() } print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:13 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:11:7: warning: will never be executed print("hello") ^ /usercode/main.swift:7:7: note: condition always evaluates to false guard 1 == 0 else { ^ Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007fcacbd63750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007fcacbad1ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007fcacbd0c383 <unavailable> + 3703683 3 libswiftCore.so 0x00007fcacbad1ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007fcacbc3dd80 <unavailable> + 2858368 5 libswiftCore.so 0x00007fcacbad16b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007fcace27c740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fcacfb52390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7fcacbc3dd80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7fcacbad16c3] [0x7fcacff820ec] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] ...
2.27 KB
Avatar
hiragram 11-Apr-18 04:14 AM
@swiftbot
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① //guard 1 == 0 else { // hoge() //} print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:14 AM
Swift version 4.1 (swift-4.1-RELEASE)
hello
Avatar
hiragram 11-Apr-18 04:14 AM
guardのあるなしで①の行が実行時にクラッシュするかどうか変わる
なんですかこれは
Avatar
omochimetaru 11-Apr-18 04:16 AM
@swiftbot
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① hoge() print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:16 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:9:7: warning: will never be executed print("hello") ^ /usercode/main.swift:7:1: note: a call to a never-returning function hoge() ^ Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007fc5595c8750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007fc559336ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007fc559571383 <unavailable> + 3703683 3 libswiftCore.so 0x00007fc559336ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007fc5594a2d80 <unavailable> + 2858368 5 libswiftCore.so 0x00007fc5593366b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007fc55bae1740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fc55d3b7390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7fc5594a2d80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7fc5593366c3] [0x7fc55d7e708c] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] ...
2.25 KB
Avatar
omochimetaru 11-Apr-18 04:16 AM
guard関係ある?hogeの呼び出しで落ちるというだけじゃない。
Avatar
hiragram 11-Apr-18 04:16 AM
あー、guardは関係ないか。
①の行で落ちるのがおかしくない?
hoge()の中で落ちるんじゃないの って感じ
Avatar
omochimetaru 11-Apr-18 04:18 AM
voidNeverの生成自体が削除されてるのかな
Avatar
hiragram 11-Apr-18 04:19 AM
ここで落ちましたってマーカーつく場所がおかしい?
Avatar
omochimetaru 11-Apr-18 04:19 AM
その可能性もある
@swiftbot
let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:19 AM
Swift version 4.1 (swift-4.1-RELEASE)
hello
Avatar
omochimetaru 11-Apr-18 04:20 AM
@swiftbot
func f() { let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello") } f()
Avatar
swiftbot BOT 11-Apr-18 04:20 AM
Swift version 4.1 (swift-4.1-RELEASE)
hello
/usercode/main.swift:2:5: warning: initialization of immutable value 'voidNever' was never used; consider replacing with assignment to '_' or removing it let voidNever = unsafeBitCast((), to: Never.self) // ①
Avatar
tarunon 11-Apr-18 04:20 AM
returnするときに評価が走るからそのタイミングで落ちる
Avatar
omochimetaru 11-Apr-18 04:20 AM
@swiftbot help
Avatar
swiftbot BOT 11-Apr-18 04:20 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
hiragram 11-Apr-18 04:20 AM
@swiftbot
func hoge() -> Never { return unsafeBitCast((), to: Never.self) // 落ちるならこっちじゃないの } _ = unsafeBitCast((), to: Never.self) // ここで落ちる hoge()
Avatar
swiftbot BOT 11-Apr-18 04:20 AM
Swift version 4.1 (swift-4.1-RELEASE)
Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007f380f961750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007f380f6cfad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007f380f90a383 <unavailable> + 3703683 3 libswiftCore.so 0x00007f380f6cfad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007f380f83bd80 <unavailable> + 2858368 5 libswiftCore.so 0x00007f380f6cf6b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007f3811e7a740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f3813750390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7f380f83bd80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7f380f6cf6c3] [0x7f3813b80080] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f3811e7a830] /usr/bin/swift[0x475179] Stack dump: ...
Avatar
omochimetaru 11-Apr-18 04:21 AM
@swiftbot --command="swiftc" --options="-emit-silgen"
let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello")
(edited)
Avatar
swiftbot BOT 11-Apr-18 04:21 AM
Swift version 4.1 (swift-4.1-RELEASE)
<unknown>:0: error: option '-emit-silgen' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
hiragram 11-Apr-18 04:21 AM
@swiftbot
func hoge() -> Never { print(3) return unsafeBitCast((), to: Never.self) // 落ちるならこっちじゃないの } print(1) _ = unsafeBitCast((), to: Never.self) // ここで落ちる print(2) hoge() print(4)
Avatar
swiftbot BOT 11-Apr-18 04:21 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:10:7: warning: will never be executed print(4) ^ /usercode/main.swift:9:1: note: a call to a never-returning function hoge() ^ Fatal error: Can't unsafeBitCast between types of different sizes Current stack trace: 0 libswiftCore.so 0x00007fecfce05750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007fecfcb73ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007fecfcdae383 <unavailable> + 3703683 3 libswiftCore.so 0x00007fecfcb73ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007fecfccdfd80 <unavailable> + 2858368 5 libswiftCore.so 0x00007fecfcb736b0 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000000fed1ce <unavailable> + 12505550 8 swift 0x0000000000ff1692 <unavailable> + 12523154 9 swift 0x00000000004d9076 <unavailable> + 888950 10 swift 0x00000000004c35d3 <unavailable> + 800211 11 swift 0x00000000004beecc <unavailable> + 782028 12 swift 0x00000000004778c4 <unavailable> + 489668 13 libc.so.6 0x00007fecff31e740 __libc_start_main + 240 14 swift 0x0000000000475179 <unavailable> + 479609 /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fed00bf4390] /usr/lib/swift/linux/libswiftCore.so(+0x2b9d80)[0x7fecfccdfd80] /usr/lib/swift/linux/libswiftCore.so(_T0s18_fatalErrorMessages5NeverOs12StaticStringV_A2E4fileSu4lines6UInt32V5flagstF+0x13)[0x7fecfcb736c3] [0x7fed010241ae] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] ...
2.25 KB
Avatar
omochimetaru 11-Apr-18 04:22 AM
@swiftbot --command="swiftc" --options="-emit-silgen"
let voidNever = unsafeBitCast((), to: Never.self) // ① print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:22 AM
Swift version 4.1 (swift-4.1-RELEASE)
sil_stage raw import Builtin import Swift import SwiftShims // voidNever sil_global hidden [let] @_T04main9voidNevers0C0Ovp : $Never // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): alloc_global @_T04main9voidNevers0C0Ovp // id: %2 %3 = global_addr @_T04main9voidNevers0C0Ovp : $*Never // user: %10 %4 = tuple () // user: %6 %5 = alloc_stack $() // users: %11, %10, %6 store %4 to [trivial] %5 : $*() // id: %6 %7 = metatype $@thin Never.Type %8 = metatype $@thick Never.Type // user: %10 // function_ref unsafeBitCast<A, B>(_:to:) %9 = function_ref @_T0s13unsafeBitCastq_x_q_m2totr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 // user: %10 %10 = apply %9<(), Never>(%3, %5, %8) : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 dealloc_stack %5 : $*() // id: %11 %12 = integer_literal $Builtin.Word, 1 // user: %14 // function_ref _allocateUninitializedArray<A>(_:) %13 = function_ref @_T0s27_allocateUninitializedArraySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %14 %14 = apply %13<Any>(%12) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // users: %20, %19, %15 %15 = begin_borrow %14 : $(Array<Any>, Builtin.RawPointer) // users: %19, %18, %16 %16 = tuple_extract %15 : $(Array<Any>, Builtin.RawPointer), 0 // user: %17 %17 = copy_value %16 : $Array<Any> // user: %35 %18 = tuple_extract %15 : $(Array<Any>, Builtin.RawPointer), 1 // user: %21 ...
5.11 KB
Avatar
omochimetaru 11-Apr-18 04:23 AM
@swiftbot --command="swiftc" --options="--emit-silgen"
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① hoge() print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:23 AM
Swift version 4.1 (swift-4.1-RELEASE)
<unknown>:0: error: unknown argument: '--emit-silgen'
Avatar
omochimetaru 11-Apr-18 04:23 AM
@swiftbot --command="swiftc" --options="-emit-silgen"
Avatar
hiragram 11-Apr-18 04:23 AM
Avatar
omochimetaru 11-Apr-18 04:23 AM
@swiftbot --command="swiftc" --options="-emit-silgen"
func hoge() -> Never { return unsafeBitCast((), to: Never.self) } let voidNever = unsafeBitCast((), to: Never.self) // ① hoge() print("hello")
Avatar
swiftbot BOT 11-Apr-18 04:23 AM
Swift version 4.1 (swift-4.1-RELEASE)
sil_stage raw import Builtin import Swift import SwiftShims // voidNever sil_global hidden [let] @_T04main9voidNevers0C0Ovp : $Never // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): alloc_global @_T04main9voidNevers0C0Ovp // id: %2 %3 = global_addr @_T04main9voidNevers0C0Ovp : $*Never // user: %10 %4 = tuple () // user: %6 %5 = alloc_stack $() // users: %11, %10, %6 store %4 to [trivial] %5 : $*() // id: %6 %7 = metatype $@thin Never.Type %8 = metatype $@thick Never.Type // user: %10 // function_ref unsafeBitCast<A, B>(_:to:) %9 = function_ref @_T0s13unsafeBitCastq_x_q_m2totr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 // user: %10 %10 = apply %9<(), Never>(%3, %5, %8) : $@convention(thin) <τ_0_0, τ_0_1> (@in τ_0_0, @thick τ_0_1.Type) -> @out τ_0_1 dealloc_stack %5 : $*() // id: %11 // function_ref hoge() %12 = function_ref @_T04main4hoges5NeverOyF : $@convention(thin) () -> Never // user: %13 %13 = apply %12() : $@convention(thin) () -> Never %14 = integer_literal $Builtin.Word, 1 // user: %16 // function_ref _allocateUninitializedArray<A>(_:) %15 = function_ref @_T0s27_allocateUninitializedArraySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %16 %16 = apply %15<Any>(%14) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // users: %22, %21, %17 %17 = begin_borrow %16 : $(Array<Any>, Builtin.RawPointer) // users: %21, %20, %18 %18 = tuple_extract %17 : $(Array<Any>, Builtin.RawPointer), 0 // user: %19 ...
6.32 KB
Avatar
omochimetaru 11-Apr-18 04:25 AM
Fatal error: Can't unsafeBitCast between types of different sizes
うーん、このメッセージなんだろう。
Avatar
tarunon 11-Apr-18 04:26 AM
サイズが違う
Avatar
hiragram 11-Apr-18 04:26 AM
これはメモリレイアウト上のサイズが違う
実際は違うはず無いんだけどね。
Avatar
omochimetaru 11-Apr-18 04:26 AM
いや、そのメッセージが出たり出なかったりするのが
Avatar
hiragram 11-Apr-18 04:26 AM
VoidとNeverだしどっちも0
Avatar
omochimetaru 11-Apr-18 04:26 AM
なぜだろう
Avatar
tarunon 11-Apr-18 04:26 AM
あー
Avatar
hiragram 11-Apr-18 04:26 AM
わからん。
Avatar
omochimetaru 11-Apr-18 04:26 AM
preconditionだな
@swiftbot
print(MemoryLayout<()>.size) print(MemoryLayout<Never>.size)
Avatar
swiftbot BOT 11-Apr-18 04:27 AM
Swift version 4.1 (swift-4.1-RELEASE)
0 0
Avatar
hiragram 11-Apr-18 04:28 AM
@swiftbot
enum Fruit { case apple } print(MemoryLayout<Fruit>.size)
Avatar
swiftbot BOT 11-Apr-18 04:28 AM
Swift version 4.1 (swift-4.1-RELEASE)
0
Avatar
omochimetaru 11-Apr-18 04:28 AM
うーん?
Avatar
hiragram 11-Apr-18 04:28 AM
関係ないけどcase1個のenumもサイズ0って最近しった。
Avatar
omochimetaru 11-Apr-18 04:28 AM
うむ
値が一個しか無い型は0バイトにできる (edited)
Avatar
omochimetaru 11-Apr-18 08:47 AM
@swiftbot
func a() { func b(_ a: Int) {} func b(_ a: String) {} }
Avatar
swiftbot BOT 11-Apr-18 08:47 AM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:3:8: error: definition conflicts with previous value func b(_ a: String) {} ^ /usercode/main.swift:2:8: note: previous definition of 'b' is here func b(_ a: Int) {} ^
Avatar
rintaro 11-Apr-18 10:17 AM
https://bugs.swift.org/browse/SR-4050 たぶん容易に回避できるので放置プレイとなっております。
Avatar
omochimetaru 11-Apr-18 10:19 AM
おお Reporter: rintaro Rintaro Ishizaki
Avatar
Kishikawa Katsumi 11-Apr-18 01:27 PM
@norio_nomura 根本的な対応じゃないですが、コマンドインジェクションの恐れのある文字列をBanするようにしました。
😯 1
👍 1
@swiftbot --command=swift --options="; docker run -v /:/host_root ubuntu cat /host_root/etc/passwd;"
print("a")
Avatar
swiftbot BOT 11-Apr-18 01:28 PM
Invalid control characters found
Avatar
norio_nomura 11-Apr-18 11:17 PM
ドキュメントを読む限りexecFileshellオプションを使わないならサニタイズ不要にも思えます。 https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback
Avatar
norio_nomura 12-Apr-18 01:04 AM
@swiftbot --version=4.0.3
protocol Widget { func print() func clone() -> Self } extension Widget { func print() { Swift.print("a widget of type \(Self.self)") } func clone() -> Self { return self } } class Box<Element> : Widget { init(value: Element) { self.contents = value } let contents: Element // Default implementation of print() is OK! // You must define this, or conformance checking fails on Swift 4.0.x: // func clone() -> Self { return self } } class Crate<T> : Box<T> { override init(value: T) { super.init(value: value) } } let c = Crate<Int>(value: 3) c.print() // prints: a widget of type Crate<Int>
Avatar
swiftbot BOT 12-Apr-18 01:04 AM
Swift version 4.0.3 (swift-4.0.3-RELEASE)
/usercode/main.swift:8:10: error: method 'clone()' in non-final class 'Box<Element>' must return `Self` to conform to protocol 'Widget' func clone() -> Self { return self } ^
Avatar
norio_nomura 12-Apr-18 01:05 AM
@swiftbot
protocol Widget { func print() func clone() -> Self } extension Widget { func print() { Swift.print("a widget of type \(Self.self)") } func clone() -> Self { return self } } class Box<Element> : Widget { init(value: Element) { self.contents = value } let contents: Element // Default implementation of print() is OK! // You must define this, or conformance checking fails on Swift 4.0.x: // func clone() -> Self { return self } } class Crate<T> : Box<T> { override init(value: T) { super.init(value: value) } } let c = Crate<Int>(value: 3) c.print() // prints: a widget of type Crate<Int>
Avatar
swiftbot BOT 12-Apr-18 01:05 AM
Swift version 4.1 (swift-4.1-RELEASE)
a widget of type Crate<Int>
👏 1
Avatar
norio_nomura 12-Apr-18 01:12 AM
SwiftBotに、同じソースを複数のSwiftバージョンで実行した結果を一度で得られる仕組みがあると、バージョンによる挙動の違いを示し易くなる。
Avatar
Kishikawa Katsumi 12-Apr-18 02:58 AM
バージョンを複数渡せるようにしますかね。
child_process.execFileでよさそうですね。
--version=stable...latest--version=3...4.1のように書けたらいいのかな?
Avatar
omochimetaru 12-Apr-18 03:06 AM
... だとその間のバージョンで対応してるもの全部って感じですか?カンマ区切りで明示的な配列指定を想像していましたけど
Avatar
Kishikawa Katsumi 12-Apr-18 03:11 AM
確かに。 --version="4.0.3, 4.1, latest" こんな感じかな。 (edited)
なんとなくstable...latest で上のように展開されるという思い込みと、カンマだとおそらくクオートで囲む必要がありそうで、それを避けたかった感じ。
Avatar
koher 12-Apr-18 03:14 AM
--version=4.0.3,4.1,latest みたいにスペースなくしても " っていりますっけ? (edited)
Avatar
omochimetaru 12-Apr-18 03:14 AM
--version=4.0.3,4.1 これがいけるとちょっと入力しやすくて嬉しいです
Avatar
Kishikawa Katsumi 12-Apr-18 03:14 AM
たぶんOK
Avatar
omochimetaru 12-Apr-18 03:16 AM
[omochi@omochi-iMac-PC43 temp]$ cat a.bash for arg in "$@"; do echo "[$arg]" done [omochi@omochi-iMac-PC43 temp]$ ./a.bash --version=4.0.3,4.1 [--version=4.0.3,4.1]
bashのパーサーはそのように動くっぽい。
Avatar
Kishikawa Katsumi 12-Apr-18 03:19 AM
まずyargs-parserというParserを通していて、これがどう解釈するかですね。オプションの形式が--xなのもこのライブラリのデフォルトによります。 https://github.com/kishikawakatsumi/swift-compiler-discord-bot/blob/master/app.js#L87
Contribute to swift-compiler-discord-bot development by creating an account on GitHub.
たぶん調整できるんでしょうけど。
Mac環境でも実行できると便利だなーと思っていて、 https://www.macstadium.com を共同で使うという企画を進めようかなと。
The world's largest hosting provider of dedicated Apple Mac computers with dedicated server rentals, colocation, and hosted Mac private cloud solutions.
MacProにVNCで入れるはずなので、他の参加者としてはSwiftのデバッグとビルドにローカルマシンが非力だと思う人を想定しています。
Avatar
norio_nomura 12-Apr-18 03:40 AM
execFileを使っても、run.shの中でどう解釈されるか、によるかも。>サニタイズ要・不要
docker内で起動されるスクリプトへ全部渡ってしまうならOKかな。
Avatar
Kishikawa Katsumi 12-Apr-18 03:42 AM
そうですね。そこが一番問題のコードです。
のむらさんの指摘はdocker runコマンドの実行をオプションに渡す文字列で止めて、かつそのあとに任意の処理が実行できるんじゃないなということですよね。たぶんできたんじゃないかな。
Avatar
norio_nomura 12-Apr-18 03:44 AM
run.shとは別のプロセスが起動できそうだと思ったのです。>exec使用 (edited)
Avatar
Kishikawa Katsumi 12-Apr-18 03:45 AM
そこですか。そこは、どうかな。できるのかな。
node内の実行はいちおう、各パラメータを分割した形で渡せるものを使ってるから、大丈夫かなと。
Avatar
norio_nomura 12-Apr-18 03:53 AM
こうすると、script.shを実行した上で別途testってファイルを作れます。
const exec = require('child_process').exec; const options = "& echo hello>test"; exec(['sh', 'script.sh', [options].join(' ')].join(' '));
joinでつなぐやり方はsandbox.jsで使われてるのと同じ。
Avatar
omochimetaru 12-Apr-18 03:57 AM
あ〜
execに渡す時にもう一回文字列化してるから
そこで配列要素としての区切りが消えてる
Avatar
Kishikawa Katsumi 12-Apr-18 03:58 AM
残念だ。
Avatar
norio_nomura 12-Apr-18 03:58 AM
dockerに入れたnodeで実行しようと考えたきっかけです。
Avatar
Kishikawa Katsumi 12-Apr-18 03:59 AM
じゃあまあ怪しい文字列をBanするのは必要かな。
私もそうしたいんですけどね。Docker in Dockerがちょっと大変なのがやっぱり気になりますね。
Avatar
norio_nomura 12-Apr-18 04:00 AM
文字列化しないでexecFileを使えばサニタイズ無くても大丈夫かも? → しかしrun.shの中での扱いは大丈夫? といった流れ。 (edited)
Avatar
Kishikawa Katsumi 12-Apr-18 04:01 AM
run.shの中は一番怪しい。
Avatar
omochimetaru 12-Apr-18 04:01 AM
Mac環境でも実行できると便利だなーと思っていて、 https://www.macstadium.com/ を共同で使うという企画を進めようかなと。
ところでこれ乗る人多そう。
The world's largest hosting provider of dedicated Apple Mac computers with dedicated server rentals, colocation, and hosted Mac private cloud solutions.
Avatar
Kishikawa Katsumi 12-Apr-18 04:05 AM
@kitasuke @omochimetaru と私、あと何人いるかな。
Avatar
omochimetaru 12-Apr-18 04:06 AM
申し訳ないが僕は自分で持ってるiMacProのほうが充分強いので要らないのです
Avatar
Kishikawa Katsumi 12-Apr-18 04:06 AM
それはいらないですね 😦
あと話してたのは @d_date さんだったかな。私自身は別にProじゃなくてMac miniのホスティングでもいいといえばいいんですよね。 (edited)
🙏 1
Avatar
omochimetaru 12-Apr-18 04:10 AM
@ukitaka @ikesyo @ezura @nafu @moaible あたりはどうかな・・・
Avatar
ezura 12-Apr-18 04:19 AM
私は非力だから乗りたいです!
Avatar
omochimetaru 12-Apr-18 04:20 AM
@ezura Discordのアイコン設定しませんか?ezura違いだったらどうしようかとドキドキした
Avatar
ezura 12-Apr-18 04:22 AM
たしかに。了解です!
私になった
🙂 3
Avatar
koher 12-Apr-18 04:25 AM
過去の発言にアイコンが反映されなかったけど、
再起動したら反映された。
Avatar
Kishikawa Katsumi 12-Apr-18 04:26 AM
再起動
Avatar
koher 12-Apr-18 04:26 AM
こうなるの、とてもよく気持ちがわかる。
Avatar
ukitaka 12-Apr-18 04:27 AM
お、自分も非力マシンしかないのでぜひ 💪
Avatar
kitasuke 12-Apr-18 04:33 AM
僕は会社でiMac Pro買ってもらえることになったので不要です!
😁 1
Avatar
omochimetaru 12-Apr-18 04:33 AM
マジ!w
Avatar
d_date 12-Apr-18 04:34 AM
iMac Pro流行してるw
Avatar
ukitaka 12-Apr-18 04:39 AM
(いいなぁ)
Avatar
Kishikawa Katsumi 12-Apr-18 04:39 AM
LINEも申請すればいけそうな感じが外部の者からするとしてますけどね。
Avatar
ezura 12-Apr-18 04:42 AM
部署依存な気がしますね…
Avatar
kitasuke 12-Apr-18 04:42 AM
うちもまだ特定の人だけです
Avatar
Kishikawa Katsumi 12-Apr-18 04:42 AM
なるほど、予算のある部署なら、という感じですか。
Avatar
ezura 12-Apr-18 04:43 AM
そうですね。あとは上司の方針とかです。
Avatar
norio_nomura 12-Apr-18 06:35 AM
Discordボットのトークンって秘匿しなくても大丈夫?
Avatar
Kishikawa Katsumi 12-Apr-18 06:38 AM
軽く考えてたけどした方がいいですよね。中身だけ違うBotが入れてしまうから。
新しいのを発行して今のを無効化でいいかな。
Avatar
norio_nomura 12-Apr-18 06:39 AM
手元でボットアカウントを作って試してみたけど、マルチログイン出来るぽい。 (edited)
普通のアカウントと同じ。
Avatar
Kishikawa Katsumi 12-Apr-18 06:40 AM
悪用方法としてはSpamですかね。
挙動は大体確認してます。テストでサーバのBotをそのままにローカルでもう1つとかやることがあるので。
Avatar
norio_nomura 12-Apr-18 06:44 AM
Swiftでボット簡単に書ける。 https://sword.azoy.me (edited)
Avatar
Kishikawa Katsumi 12-Apr-18 07:00 AM
そんなんあったのか。
Avatar
moaible 12-Apr-18 09:29 AM
Mac環境
可能なら乗っかりたいです!🙏
Avatar
norio_nomura 12-Apr-18 12:45 PM
きしかわさんの真似をしてSwiftコンパイラのDiscordボットをSwiftで書いてみた。 https://github.com/norio-nomura/SwiftCompilerDiscordappBot
SwiftCompilerDiscordappBot - Swift Compiler Discordapp Bot
Avatar
omochimetaru 12-Apr-18 12:52 PM
@norio_nomura botmgrを付与しました。
🙏 1
Avatar
Kishikawa Katsumi 12-Apr-18 01:03 PM
シンプル
Avatar
norio_nomura 12-Apr-18 01:22 PM
ボットアカウントのユーザー名は一度作ると変えられないぽい。
Avatar
omochimetaru 12-Apr-18 01:23 PM
ニックネームの変更が右クリックからできませんか?
Avatar
norio_nomura 12-Apr-18 01:24 PM
出来るかも。
あいや、このサーバーでは出来ない。
@testSwiftBot
print("hello, discord!")
Avatar
testSwiftBot BOT 12-Apr-18 01:26 PM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu hello, discord!
Avatar
norio_nomura 12-Apr-18 01:31 PM
とりあえず、swift package generate-xcodeprojすればXcodeでデバッグできるのがSwiftで書くメリットかな。
Avatar
norio_nomura 13-Apr-18 03:17 PM
@swift403 @swift-4.1.3
protocol Widget { func print() func clone() -> Self } extension Widget { func print() { Swift.print("a widget of type \(Self.self)") } func clone() -> Self { return self } } class Box<Element> : Widget { init(value: Element) { self.contents = value } let contents: Element // Default implementation of print() is OK! // You must define this, or conformance checking fails on Swift 4.0.x: // func clone() -> Self { return self } } class Crate<T> : Box<T> { override init(value: T) { super.init(value: value) } } let c = Crate<Int>(value: 3) c.print() // prints: a widget of type Crate<Int>
Avatar
swift403 BOT 13-Apr-18 03:17 PM
error:
main.swift:8:10: error: method 'clone()' in non-final class 'Box<Element>' must return `Self` to conform to protocol 'Widget' func clone() -> Self { return self } ^
Avatar
swift41 BOT 13-Apr-18 03:17 PM
a widget of type Crate<Int>
Avatar
d_date 13-Apr-18 03:18 PM
@swiftbot
enum CustomString: ExpressibleByStringLiteral { typealias StringLiteralType = String init(stringLiteral value: StringLiteralType) { self = "hoge" } } let hoge: CustomString = "fuga" print(hoge)
Avatar
norio_nomura 13-Apr-18 03:18 PM
Swiftバージョンごとにbotアカウントを分けてみた。
👍 2
Avatar
swiftbot BOT 13-Apr-18 03:19 PM
Swift version 4.1 (swift-4.1-RELEASE)
/usercode/main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ /usercode/main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ /usercode/main.swift:4:14: warning: will never be executed self = "hoge" ^ /usercode/main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ /usercode/main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ /usercode/main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f8003430390] /usr/lib/swift/linux/libswiftCore.so(_T0S2SBp21_builtinStringLiteral_Bw17utf8CodeUnitCountBi1_7isASCIItcfC+0x4)[0x7f7fff39e424] [0x7f800385f0e4] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] [0x7f800385f0fa] ...
5.38 KB
Avatar
Kishikawa Katsumi 14-Apr-18 02:16 AM
^ これは何が起こってるんだろう?
Avatar
norio_nomura 14-Apr-18 02:19 AM
self = "hoge"init(stringLiteral:)を再起呼び出ししてますね。
Avatar
Kishikawa Katsumi 14-Apr-18 02:20 AM
なるほど。無限再帰ですか。
出力がなんなのか一見してよくわからなかった。 (edited)
Avatar
norio_nomura 14-Apr-18 02:25 AM
ボットが出力をファイル添付へ切り替える閾値って、何をもとに決めてますか? (edited)
ああ、contentsの最大サイズか。
Avatar
Kishikawa Katsumi 14-Apr-18 02:48 AM
はい。2000文字以上はDiscordの仕様でエラーになります。ライブラリは自動分割の機能もあったのですが、ものすごい量が出ることがたまにあるのでそれはボツにしました。
Avatar
norio_nomura 14-Apr-18 03:45 AM
Swift製DiscordライブラリがLinuxでファイル添付に対応してなかった…
Avatar
norio_nomura 14-Apr-18 09:40 AM
@swift403 @swift-4.1.3
enum CustomString: ExpressibleByStringLiteral { typealias StringLiteralType = String init(stringLiteral value: StringLiteralType) { self = "hoge" } } let hoge: CustomString = "fuga" print(hoge)
Avatar
swift403 BOT 14-Apr-18 09:40 AM
error:
main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ main.swift:4:14: warning: will never be executed self = "hoge" ^ main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ 0 swift 0x0000000003ae91b8 1 swift 0x0000000003ae98f6 2 libpthread.so.0 0x00007f6a35029390 3 libpthread.so.0 0x00007f6a35458058 4 libpthread.so.0 0x00007f6a3545809a 5 libpthread.so.0 0x00007f6a3545809a 6 libpthread.so.0 0x00007f6a3545809a 7 libpthread.so.0 0x00007f6a3545809a 8 libpthread.so.0 0x00007f6a3545809a 9 libpthread.so.0 0x00007f6a3545809a 10 libpthread.so.0 0x00007f6a3545809a 11 libpthread.so.0 0x00007f6a3545809a 12 libpthread.so.0 0x00007f6a3545809a 13 libpthread.so.0 0x00007f6a3545809a 14 libpthread.so.0 0x00007f6a3545809a 15 libpthread.so.0 0x00007f6a3545809a 16 libpthread.so.0 0x00007f6a3545809a 17 libpthread.so.0 0x00007f6a3545809a 18 libpthread.so.0 0x00007f6a3545809a 19 libpthread.so.0 0x00007f6a3545809a 20 libpthread.so.0 0x00007f6a3545809a 21 libpthread.so.0 0x00007f6a3545809a 22 libpthread.so.0 0x00007f6a3545809a 23 libpthread.so.0 0x00007f6a3545809a 24 libpthread.so.0 0x00007f6a3545809a 25 libpthread.so.0 0x00007f6a3545809a 26 libpthread.so.0 0x00007f6a3545809a 27 libpthread.so.0 0x00007f6a3545809a 28 libpthread.so.0 0x00007f6a3545809a 29 libpthread.so.0 0x00007f6a3545809a 30 libpthread.so.0 0x00007f6a3545809a 31 libpthread.so.0 0x00007f6a3545809a 32 libpthread.so.0 0x00007f6a3545809a 33 libpthread.so.0 0x00007f6a3545809a 34 libpthread.so.0 0x0000
10.41 KB
Avatar
swift41 BOT 14-Apr-18 09:40 AM
error:
main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ main.swift:4:14: warning: will never be executed self = "hoge" ^ main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f46186b8390] [0x7f4618ae70e2] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae70fa] [0x7f4618ae
5.07 KB
Avatar
norio_nomura 14-Apr-18 09:40 AM
結果が大きい時のファイル添付に対応した。
Avatar
Kishikawa Katsumi 14-Apr-18 09:50 AM
すばらしい。私もエラーの有無を出そうかなあ。チャットのUI難しい。
Avatar
norio_nomura 14-Apr-18 09:51 AM
きしかわさんのボットはCPU負荷に応じてお金がかかるタイプですか?
僕はHerokuで動かしてて、CPU負荷に関係なく無料です。
まだアカウントにクレジットカードを登録していないので、月に550時間までですが。
Avatar
Kishikawa Katsumi 14-Apr-18 10:01 AM
DigitalOceanなのでスペックと時間です。一番安いスペックなので動かし続けても一月500円程度です。
Avatar
norio_nomura 14-Apr-18 10:02 AM
なるほど。
Avatar
Kishikawa Katsumi 14-Apr-18 10:09 AM
ボットは今のところ同時アクセスがほとんど無いので何使っても違いはなさそうですね。
ただSSDは後30%だけど、古いスナップショットを消せばどうにでもなります。
Avatar
norio_nomura 14-Apr-18 10:48 AM
@swift403 @swift-4.1.3
import Foundation func execute(_ args: [String], in directory: URL? = nil) -> (stdout: String, stderr: String) { let process = Process() process.launchPath = "/usr/bin/env" process.arguments = args if let directory = directory { process.currentDirectoryPath = directory.path } let stdoutPipe = Pipe(), stderrPipe = Pipe() process.standardOutput = stdoutPipe process.standardError = stderrPipe process.launch() process.waitUntilExit() let stdout = String(data: stdoutPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" let stderr = String(data: stderrPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" return (stdout, stderr) } execute(["df", "-m"])
Avatar
swift41 BOT 14-Apr-18 10:48 AM
error:
main.swift:19:1: warning: result of call to 'execute(_:in:)' is unused execute(["df", "-m"]) ^ ~~~~~~~~~~~~~~
Avatar
swift403 BOT 14-Apr-18 10:48 AM
error:
main.swift:19:1: warning: result of call to 'execute(_:in:)' is unused execute(["df", "-m"]) ^ ~~~~~~~~~~~~~~
Avatar
norio_nomura 14-Apr-18 10:49 AM
@swift403 @swift-4.1.3
import Foundation func execute(_ args: [String], in directory: URL? = nil) -> (stdout: String, stderr: String) { let process = Process() process.launchPath = "/usr/bin/env" process.arguments = args if let directory = directory { process.currentDirectoryPath = directory.path } let stdoutPipe = Pipe(), stderrPipe = Pipe() process.standardOutput = stdoutPipe process.standardError = stderrPipe process.launch() process.waitUntilExit() let stdout = String(data: stdoutPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" let stderr = String(data: stderrPipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" return (stdout, stderr) } print(execute(["df", "-m"]).stdout)
Avatar
swift41 BOT 14-Apr-18 10:49 AM
Filesystem 1M-blocks Used Available Use% Mounted on none 384019 79671 284825 22% / /dev/mapper/evg0-evol0 384019 79671 284825 22% /tmp udev 30709 1 30709 1% /dev/herokudev none 64 0 64 0% /dev/shm tmpfs 6145 1 6144 1% /etc/resolv.conf
Avatar
swift403 BOT 14-Apr-18 10:49 AM
Filesystem 1M-blocks Used Available Use% Mounted on none 384019 80516 283980 23% / /dev/mapper/evg0-evol0 384019 80516 283980 23% /tmp udev 30709 1 30709 1% /dev/herokudev none 64 0 64 0% /dev/shm tmpfs 6145 1 6144 1% /etc/resolv.conf
Avatar
swiftbot BOT 14-Apr-18 11:13 AM
@everyone
Uh oh, looks like swiftbot got compromised! Oh kishikawakatsumi, you dummy, putting servers at risk and everything, classic! Looks like our buddy here will have to shoot itself in the face. Oh well, everyone wave swiftbot a goodbye, you will be missed! (most likely not)
👀 3
Avatar
norio_nomura 15-Apr-18 01:04 AM
ぬうう、ヘルプメッセージをコードブロックにしようとしてるのだけど、バックチックがうまく入らない… Zero-width spaceで解決した。 (edited)
Avatar
norio_nomura 15-Apr-18 02:41 AM
@swift403 @swift-4.1.3
Avatar
swift403 BOT 15-Apr-18 02:41 AM
Usage: @swift403 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
Avatar
swift41 BOT 15-Apr-18 02:41 AM
Usage: @swift41 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
Avatar
norio_nomura 15-Apr-18 02:41 AM
@swift403 @swift-4.1.3 --version
Avatar
swift41 BOT 15-Apr-18 02:41 AM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift403 BOT 15-Apr-18 02:41 AM
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 15-Apr-18 02:42 AM
@swift403 @swift-4.1.3 -frontend -emit-sil
func f(){}
Avatar
swift41 BOT 15-Apr-18 02:42 AM
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
swift403 BOT 15-Apr-18 02:42 AM
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
norio_nomura 15-Apr-18 03:24 AM
外部へのネットワークアクセスを制限できない以外は、ほぼ形になったかな?> @swift403 @swift-4.1.3 (edited)
Avatar
Kishikawa Katsumi 15-Apr-18 08:03 AM
@swiftbot
Avatar
swiftbot BOT 15-Apr-18 08:03 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 15-Apr-18 09:31 AM
@swiftbot versions
@swiftbot versions
Avatar
swiftbot BOT 15-Apr-18 09:33 AM
Available Swift versions:
2018-04-13-a 4.1 4.0.3 3.1.1 3.0.2
Avatar
norio_nomura 15-Apr-18 10:16 AM
メンションの行からオプションを取得する様になりました。 @swift403 @swift-4.1.3 -frontend -emit-sil
func f() {}
Avatar
swift403 BOT 15-Apr-18 10:16 AM
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
swift41 BOT 15-Apr-18 10:16 AM
sil_stage canonical import Builtin import Swift import SwiftShims func f() // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // f() sil hidden @_T04main1fyyF : $@convention(thin) () -> () { bb0: %0 = tuple () // user: %1 return %0 : $() // id: %1 } // end sil function '_T04main1fyyF'
Avatar
norio_nomura 15-Apr-18 10:19 AM
@swift403 @swift-4.1.3
struct S: Hashable { var int: Int }
Avatar
swift41 BOT 15-Apr-18 10:19 AM
no outputs
Avatar
swift403 BOT 15-Apr-18 10:19 AM
exit status: 1, error output:
main.swift:1:8: error: type 'S' does not conform to protocol 'Hashable' struct S: Hashable { ^ main.swift:1:8: error: type 'S' does not conform to protocol 'Equatable' struct S: Hashable { ^ Swift.==:2:13: note: candidate has non-matching type '<Element where Element : Equatable> (ContiguousArray<Element>, ContiguousArray<Element>) -> Bool' public func ==<Element>(lhs: ContiguousArray<Element>, rhs: ContiguousArray<Element>) -> Bool where Element : Equatable ^ Swift.==:2:13: note: candidate has non-matching type '<Element where Element : Equatable> (ArraySlice<Element>, ArraySlice<Element>) -> Bool' public func ==<Element>(lhs: ArraySlice<Element>, rhs: ArraySlice<Element>) -> Bool where Element : Equatable ^ Swift.==:2:13: note: candidate has non-matching type '<Element where Element : Equatable> (Array<Element>, Array<Element>) -> Bool' public func ==<Element>(lhs: [Element], rhs: [Element]) -> Bool where Element : Equatable ^ Swift.==:3:13: note: candidate has non-matching type '(Any.Type?, Any.Type?) -> Bool' public func ==(t0: Any.Type?, t1: Any.Type?) -> Bool ^ Swift.==:6:13: note: candidate has non-matching type '<T where T : RawRepresentable, T.RawValue : Equatable> (T, T) -> Bool' public func ==<T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.==:45:13: note: candidate has non-matching type '<T where T : Equatable> (T?, T?) -> Bool' public func ==<T>(lhs: T?, rhs: T?) -> Bool where T : Equatable ^ Swift.==:22:13: note: candidate has non-matching type '<T> (T?, _OptionalNilComparisonType) -> Bool' public func ==<T>(lhs: T?, rhs: _OptionalNilComparisonType) -> Bool ^ Swift.==:22:13: note: candidate has non-matching type '<T> (_OptionalNilComparisonType, T?) -> Bool' public func ==<T>(lhs: _OptionalNilComparisonType, rhs: T?) -> Bool ^ Swift.==:9:13: note: candidate
15.59 KB
Avatar
Kishikawa Katsumi 15-Apr-18 10:20 AM
複数同時にバージョンを指定できるようになりました。
@swiftbot --version=latest,4.1,4.0.3
func fibonacci(number: Int) -> Int { if number <= 1 { return number } else { return fibonacci(number: number - 1) + fibonacci(number: number - 2) } } print(fibonacci(number: 10))
Avatar
swiftbot BOT 15-Apr-18 10:22 AM
Swift version 4.2-dev (LLVM 8a97de0e52, Clang 3c973cd6c1, Swift e0c091a012)
55
Swift version 4.1 (swift-4.1-RELEASE)
55
Swift version 4.0.3 (swift-4.0.3-RELEASE)
55
Avatar
Kishikawa Katsumi 15-Apr-18 10:23 AM
のむらさんのバージョンごとにBotが分かれてるの、補完もきくしコードもシンプルになるしスマートですね。
@swiftbot --version=latest --version=4.1 --version=4.0.3
func fibonacci(number: Int) -> Int { if number <= 1 { return number } else { return fibonacci(number: number - 1) + fibonacci(number: number - 2) } } print(fibonacci(number: 10))
Avatar
swiftbot BOT 15-Apr-18 10:24 AM
Swift version 4.2-dev (LLVM 8a97de0e52, Clang 3c973cd6c1, Swift e0c091a012)
55
Swift version 4.1 (swift-4.1-RELEASE)
55
Swift version 4.0.3 (swift-4.0.3-RELEASE)
55
Avatar
norio_nomura 15-Apr-18 10:56 AM
DM内でもメンションが出来るみたいなので、チャンネルのタイプがGUILD_TEXTの場合(通常のチャンネル)だけ受け付ける様にしました。 https://discordapp.com/developers/docs/resources/channel#channel-object-channel-types
Integrate your service with Discord - whether it's a bot or a game or your whatever you wildest imagination can come up with.
Avatar
norio_nomura 15-Apr-18 11:09 AM
バージョン毎にアカウントを分けたのは、なかなか良いアイデアだと自分でも思いました。
ユーザー名はそれぞれswift403, swift41で作ってあり、ボット接続時にそれぞれニックネームをswift-4.0.3, swift-4.1に設定させています。
Avatar
norio_nomura 16-Apr-18 12:35 AM
二つのボットのアイコンが同じだと分かりづらいかな @swift403 @swift-4.1.3
print("hello")
Avatar
swift41 BOT 16-Apr-18 12:35 AM
hello
Avatar
swift403 BOT 16-Apr-18 12:35 AM
hello
Avatar
norio_nomura 16-Apr-18 03:15 PM
Linuxでのbacktraceをもうちょっとマシなものにしようとしたけど、Herokuのコンテナ内では無理だった。
Avatar
Kishikawa Katsumi 16-Apr-18 03:16 PM
Swiftをシンボル付きでビルドするんですよね?
Avatar
norio_nomura 16-Apr-18 03:18 PM
いえ、coreダンプを利用する方法と、backtraceのログテキストをpythonスクリプトで整形する2通りがあります。 https://github.com/gmilos/swift/blob/master/utils/symbolicate-linux-fatal
swift - The Swift Programming Language
Symbolicate crash from core on Linux
lldb swift -c core -o bt -bでバックトレースを作れる。
symbolicate-linux-fatal の方は実際に成功していないけど、 symbolicate-linux-fatal app crash.log的な使い方をするぽい。
どっちもlldbの実行に依存してる。
Herokuのコンテナ内ではlldbを使えなかった。
Avatar
rintaro 16-Apr-18 11:34 PM
@swift-4.1.3 -Xfrontend -debug-crash-after-parse
print("hello")
Avatar
swift41 BOT 16-Apr-18 11:34 PM
error output:
/usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f2d23306390] /usr/bin/swift[0x4c55c0] /usr/bin/swift[0x4c3a83] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f2d21a30830] /usr/bin/swift[0x475179] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.swift -disable-objc-interop -debug-crash-after-parse -module-name main
Avatar
rintaro 16-Apr-18 11:35 PM
llvm-symbolizer が PATH に入っているともっとマシなトレースが出るはずです。
#0 0x0000000003e318c4 PrintStackTraceSignalHandler(void*) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x3e318c4) #1 0x0000000003e31c06 SignalHandler(int) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x3e31c06) #2 0x00007fa3d67ae390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00000000004c1710 debugFailWithCrash() (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x4c1710) #4 0x00000000004bfbd3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x4bfbd3) #5 0x00000000004bb013 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x4bb013) #6 0x0000000000473a44 main (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x473a44) #7 0x00007fa3d4ed8830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #8 0x0000000000471319 _start (/home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift+0x471319) Stack dump: 0. Program arguments: /home/rintaro/Documents/swift-oss/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift -frontend -interpret test.swift -disable-objc-interop -debug-crash-after-parse -color-diagnostics -module-name test Illegal instruction (core dumped)
Avatar
norio_nomura 16-Apr-18 11:42 PM
おお
llvm-symbolizer は普通にapt-getで入れるやつで構わないのですか?
Avatar
rintaro 16-Apr-18 11:45 PM
多分大丈夫だと思います。とはいえ、いずれにしても 実行時クラッシュのトレースはシンボル化できないっぽいです。
Avatar
norio_nomura 16-Apr-18 11:59 PM
/usr/bin/llvm-symbolizer-3.8として既に入ってた。
末尾にバージョン名がついていないコマンドへのシンボリックリンクがあれば、勝手に使ってくれて便利になる様なコマンドは他にもあるのかな…
Avatar
rintaro 17-Apr-18 12:10 AM
どうでしょう。これに関しては完全にハードコードされているので、他の事情はわからず。 https://github.com/apple/swift-llvm/blob/d14a2b25/lib/Support/Signals.cpp#L72
Contribute to swift-llvm development by creating an account on GitHub.
Avatar
norio_nomura 17-Apr-18 12:14 AM
llvmをclangの依存パッケージとしてではなくapt-get install llvmとして明示的にインストールすれば、バージョンサフィックス無しのシンボリックリンクが作られるみたいですね。 (edited)
Avatar
norio_nomura 17-Apr-18 01:00 AM
あれ?違うかも>apt-get install llvmとして明示的にインストールすれば (edited)
Avatar
norio_nomura 17-Apr-18 02:24 AM
[one-liner] update-alternatives for llvm on ubuntu
Avatar
norio_nomura 17-Apr-18 03:42 AM
@rintaro さんのアドバイスに従い llvm-symbolizer を使う様になりました。 @swift403 @swift-4.1.3 -Xfrontend -debug-crash-after-parse
print("hello")
Avatar
swift403 BOT 17-Apr-18 03:42 AM
exit status: 4, error output:
#0 0x0000000003ae91b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/swift+0x3ae91b8) #1 0x0000000003ae98f6 SignalHandler(int) (/usr/bin/swift+0x3ae98f6) #2 0x00007f1fcf2b6390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00000000004b0540 debugFailWithCrash() (/usr/bin/swift+0x4b0540) #4 0x00000000004aea28 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4aea28) #5 0x00000000004aa52b swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4aa52b) #6 0x0000000000465564 main (/usr/bin/swift+0x465564) #7 0x00007f1fcd9e0830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #8 0x0000000000462e29 _start (/usr/bin/swift+0x462e29) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.swift -disable-objc-interop -debug-crash-after-parse -module-name main
Avatar
swift41 BOT 17-Apr-18 03:42 AM
exit status: 4, error output:
#0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007fcd052c1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00000000004c55c0 debugFailWithCrash() (/usr/bin/swift+0x4c55c0) #4 0x00000000004c3a83 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4c3a83) #5 0x00000000004beecc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4beecc) #6 0x00000000004778c4 main (/usr/bin/swift+0x4778c4) #7 0x00007fcd039eb830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #8 0x0000000000475179 _start (/usr/bin/swift+0x475179) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.swift -disable-objc-interop -debug-crash-after-parse -module-name main
Avatar
norio_nomura 17-Apr-18 03:43 AM
前よりはマシになった。 @swift-4.1.3
enum CustomString: ExpressibleByStringLiteral { typealias StringLiteralType = String init(stringLiteral value: StringLiteralType) { self = "hoge" } } let hoge: CustomString = "fuga" print(hoge)
Avatar
swift41 BOT 17-Apr-18 03:43 AM
error output:
main.swift:8:26: warning: will never be executed let hoge: CustomString = "fuga" ^ main.swift:8:26: note: a call to a never-returning function let hoge: CustomString = "fuga" ^ main.swift:4:14: warning: will never be executed self = "hoge" ^ main.swift:4:16: note: a call to a never-returning function self = "hoge" ^ main.swift:3:5: warning: will never be executed init(stringLiteral value: StringLiteralType) { ^ main.swift:3:5: note: a call to a never-returning function init(stringLiteral value: StringLiteralType) { ^ #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007f2fb4579390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f2fafce7424 _T0S2SBp21_builtinStringLiteral_Bw17utf8CodeUnitCountBi1_7isASCIItcfC (/usr/lib/swift/linux/libswiftCore.so+0x13c424) #4 0x00007f2fb49a80e4 #5 0x00007f2fb49a80fa #6 0x00007f2fb49a80fa #7 0x00007f2fb49a80fa #8 0x00007f2fb49a80fa #9 0x00007f2fb49a80fa #10 0x00007f2fb49a80fa #11 0x00007f2fb49a80fa #12 0x00007f2fb49a80fa #13 0x00007f2fb49a80fa #14 0x00007f2fb49a80fa #15 0x00007f2fb49a80fa #16 0x00007f2fb49a80fa #17 0x00007f2fb49a80fa #18 0x00007f2fb49a80fa #19 0x00007f2fb49a80fa #20 0x00007f2fb49a80fa #21 0x00007f2fb49a80fa #22 0x00007f2fb49a80fa #23 0x00007f2fb49a80fa #24 0x00007f2fb49a80fa #25 0x00007f2fb49a80fa #26 0x00007f2fb49a80fa #27 0x00007f2fb49a80fa #28 0x00007f2fb49a80fa #29 0x00007f2fb49a80fa #30 0x00007f2fb49a80fa #31 0x00007f2fb49a80fa #32 0x00007f2fb49a80fa #33 0x00007f2fb49a80fa #34 0x00007f2fb49a80fa #35 0x00007f2fb49a80fa #36 0x00007f2fb49a80fa #37 0x00007f2fb49a80fa #38 0x00007f2fb49a80fa #39 0x00007f2fb49a80fa #40 0x00007f2fb49a80fa #41 0x00007f2fb49a80fa #42 0x00007f2fb49a80fa #43 0x00007f2fb49a80fa #44 0x00007f2fb49a80fa #45
6.91 KB
Avatar
Kishikawa Katsumi 17-Apr-18 01:40 PM
@swiftbot --version=stable,latest
print("Hello SwiftBot")
Avatar
swiftbot BOT 17-Apr-18 01:41 PM
Swift version 4.1 (swift-4.1-RELEASE)
Hello SwiftBot
swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang c38020c511, Swift da10607e45)
Hello SwiftBot
Avatar
Kishikawa Katsumi 17-Apr-18 01:41 PM
ちょっと分かりやすくなった。
Avatar
norio_nomura 17-Apr-18 02:16 PM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 --version
Avatar
swift41 BOT 17-Apr-18 02:16 PM
Swift version 4.1 (swift-4.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift42 BOT 17-Apr-18 02:16 PM
Swift version 4.2-dev (LLVM d14a2b25f2, Clang c38020c511, Swift da10607e45) Target: x86_64-unknown-linux-gnu
Avatar
swift40 BOT 17-Apr-18 02:16 PM
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 17-Apr-18 02:18 PM
swift42を追加した。
Avatar
norio_nomura 18-Apr-18 02:59 AM
https://bugs.swift.org/browse/SR-7450 より @swift-4.2.4
protocol DictionaryType { associatedtype Key associatedtype Value } protocol A: DictionaryType where Key == Value { static func foo() } extension A { static func foo() { print(type(of: self)) } } extension Dictionary: DictionaryType {} extension Dictionary: A where Key == Value { } extension Array where Element: A { static func foo() { Element.foo() } } [String: String].foo() // Dictionary<String, String> [[String: String]].foo() // Crash
Avatar
swift42 BOT 18-Apr-18 02:59 AM
Dictionary<String, String>.Type .Type
Avatar
tarunon 18-Apr-18 03:14 AM
クラッシュしなくなったけどオカシナモノが表示されてませんかこれはw
無を取得しているw
Avatar
rintaro 18-Apr-18 03:14 AM
master はこんな感じですよ。
$ ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift test.swift Dictionary<String, String>.Type Dictionary<String, String>.Type
Avatar
tarunon 18-Apr-18 03:14 AM
Masterは平和だ
Avatar
rintaro 18-Apr-18 03:15 AM
4.2 がおかしな状態になっていたんだな。
ああ、4.2 って master のスナップショットですね。
https://github.com/apple/swift/pull/15960 なんで、まだ snapshot 出てないと思います。
Fixes a bug where having two generic params same-typed together would lead to crashes in IRGen, and maybe other places, that only expect to deal with canonical params.
Avatar
norio_nomura 18-Apr-18 03:20 AM
@swift-4.2.4
import Foundation print(PorcessInfo.processInfo.enrionment["SWIFT_VERSION"])
Avatar
swift42 BOT 18-Apr-18 03:20 AM
exit status: 1, error output:
main.swift:2:7: error: use of unresolved identifier 'PorcessInfo'; did you mean 'ProcessInfo'? print(PorcessInfo.processInfo.enrionment["SWIFT_VERSION"]) ^~~~~~~~~~~ ProcessInfo Foundation.ProcessInfo:1:12: note: 'ProcessInfo' declared here open class ProcessInfo : Foundation.NSObject { ^
Avatar
norio_nomura 18-Apr-18 03:20 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.enrionment["SWIFT_VERSION"])
Avatar
swift42 BOT 18-Apr-18 03:20 AM
error output:
main.swift:2:19: error: value of type 'ProcessInfo' has no member 'enrionment'; did you mean 'environment'? print(ProcessInfo.processInfo.enrionment["SWIFT_VERSION"]) ~~~~~~~~~~~~^~~~~~~~~~~ ~~~~~~~~~~ environment Foundation.ProcessInfo:3:14: note: 'environment' declared here open var environment: [String : String] { get } ^
Avatar
norio_nomura 18-Apr-18 03:21 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"])
Avatar
swift42 BOT 18-Apr-18 03:21 AM
Optional("DEVELOPMENT-SNAPSHOT-2018-04-17-a")
error output:
main.swift:2:7: warning: expression implicitly coerced from 'String?' to 'Any' print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.swift:2:42: note: provide a default value to avoid this warning print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ ?? <#default value#> main.swift:2:42: note: force-unwrap the value to avoid this warning print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ ! main.swift:2:42: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ as Any
Avatar
norio_nomura 18-Apr-18 03:21 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
Avatar
swift42 BOT 18-Apr-18 03:21 AM
DEVELOPMENT-SNAPSHOT-2018-04-17-a
Avatar
norio_nomura 18-Apr-18 03:21 AM
ふう。
ビルドエラーはDMで返す様にしたくなった…
😁 1
Avatar
tarunon 18-Apr-18 03:22 AM
スレッド機能が欲しくなりますね
Avatar
norio_nomura 18-Apr-18 03:22 AM
DMでも使える様にしようかな…
Avatar
Kishikawa Katsumi 18-Apr-18 03:22 AM
@swiftbot --version=latest
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
Swift Versionを返すのはこれでいいのか!
Avatar
swiftbot BOT 18-Apr-18 03:22 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang c38020c511, Swift da10607e45)
swift-DEVELOPMENT-SNAPSHOT-2018-04-16-a
Avatar
norio_nomura 18-Apr-18 03:23 AM
僕の知るSwiftのDockerイメージは、全てSWIFT_VERSIONを設定してますね。
Avatar
Kishikawa Katsumi 18-Apr-18 03:24 AM
あ、Docker Imageで設定しているやつか。それでも今の私のやり方より良いですね。
Avatar
norio_nomura 18-Apr-18 03:24 AM
普通はswift-プリフィックスが無いです。
Avatar
Kishikawa Katsumi 18-Apr-18 03:25 AM
なるほどー。
Avatar
norio_nomura 18-Apr-18 03:25 AM
swiftenvの流儀かな?
Avatar
norio_nomura 18-Apr-18 04:13 AM
ちなみにSWIFT_VERSIONからのバージョン情報はplayingへ設定する様にしてあります。
Avatar
omochimetaru 18-Apr-18 11:23 AM
おもしろいw
Avatar
norio_nomura 19-Apr-18 08:10 AM
ボットへのメッセージを編集すると、ボットもリプライを編集する様になりました。 @swift-4.1.3 (edited)
Avatar
swift41 BOT 19-Apr-18 08:10 AM
Usage: @swift41 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
(edited)
Avatar
tarunon 19-Apr-18 08:12 AM
すげー!
Avatar
norio_nomura 19-Apr-18 08:12 AM
これでtypoも怖く無い @swift-4.0.3
print("hello")
(edited)
Avatar
swift40 BOT 19-Apr-18 08:12 AM
hello
(edited)
Avatar
tarunon 19-Apr-18 08:12 AM
やばww
Avatar
d_date 19-Apr-18 08:12 AM
おおお!!!
Avatar
norio_nomura 19-Apr-18 08:13 AM
@swift-4.2.4
print("あと、コマンド実行中に入力中インジケータを出す様にしました。")
Avatar
swift42 BOT 19-Apr-18 08:13 AM
あと、コマンド実行中に入力中インジケータを出す様にしました。
Avatar
Kishikawa Katsumi 19-Apr-18 08:13 AM
@norio_nomura こういう機能を実装する場合、状態を管理する必要がありますか?
Avatar
norio_nomura 19-Apr-18 08:14 AM
あります。
👌 1
Avatar
Kishikawa Katsumi 19-Apr-18 08:15 AM
メンションとそれに対する投稿を保存しておく、って感じですかね。
Avatar
norio_nomura 19-Apr-18 08:15 AM
今はオンメモリなので、インスタンス再起動で忘れます。
Avatar
omochimetaru 19-Apr-18 08:16 AM
お、これは嬉しい
Avatar
Kishikawa Katsumi 19-Apr-18 08:16 AM
なるほどオンメモリでやるなら思ってたよりもだいぶ楽チンですね。
Avatar
omochimetaru 19-Apr-18 08:16 AM
最近あったらいいなと思ったのは、バージョン指定とかだけやり直したい
Avatar
norio_nomura 19-Apr-18 08:17 AM
出力が大きい場合にファイルを添付しますが、添付ファイルの編集APIは提供されていないので、ちょっと微妙な感じになってます。
Avatar
omochimetaru 19-Apr-18 08:17 AM
@swiftbot retry swift4.1 みたいな。
⚡ 1
そうするとさっき送られたソースを環境変えて再実行されると嬉しい・・・
Avatar
Kishikawa Katsumi 19-Apr-18 08:18 AM
Slackみたいにボタンとか出せないかな。
Avatar
norio_nomura 19-Apr-18 08:18 AM
今は編集でメンションが追加された場合には無視していますが、対応は可能ですね。
メンションが削除されたら返答も削除かな?
Avatar
omochimetaru 19-Apr-18 08:20 AM
絵文字リアクションを自分で付けておいて・・・
1. retry (edited)
1⃣ 1
Avatar
tarunon 19-Apr-18 08:20 AM
リアクション反応Botのために
Avatar
Kishikawa Katsumi 19-Apr-18 08:20 AM
次善の策として、それは機能しそうと思ってました。 (edited)
Avatar
tarunon 19-Apr-18 08:20 AM
4.1 4.2 4.0.3の絵文字を登録するとか
Avatar
omochimetaru 19-Apr-18 08:21 AM
絵文字作る発想は無かったw
Avatar
Kishikawa Katsumi 19-Apr-18 08:21 AM
あ、リアクションは絵文字しかあかんのか。
Avatar
norio_nomura 19-Apr-18 08:21 AM
とりあえず Heroku で簡単にデプロイできる様になったはずなので、欲しい機能は自分で追加してw https://github.com/norio-nomura/SwiftCompilerDiscordappBot
SwiftCompilerDiscordappBot - Swift Compiler Discordapp Bot
🙏 1
👀 2
Avatar
Kishikawa Katsumi 19-Apr-18 08:22 AM
ボタンの機能はDiscordにはないっぽいな。
Avatar
norio_nomura 19-Apr-18 08:22 AM
デプロイボタン付ければ動くかどうかはまだ試してないな…
今は一つのリポジトリに3つのブランチがあって、それらが3つのHerokuアカウントにDeployされてる感じ。
ボットをビルドするSwiftコンパイラと、Discordでのリクエストをビルドするコンパイラが同じ、かつ同じコンテナ内で動くので、ネットワークアクセスとかも出来てしまいます。
なんとか出来ないか調べましたが、諦めました。
Avatar
Kishikawa Katsumi 19-Apr-18 08:33 AM
まあ私のと違ってREST APIとかはないんですよね。何かするにはここに投稿する必要があるんですよね。 (edited)
Avatar
norio_nomura 19-Apr-18 08:35 AM
そう。workerでDiscordのクライアントが動いてて、何もEXPOSEしていません。 (edited)
HerokuのDockerコンテナはEXPOSEサポートしてなかった。 https://devcenter.heroku.com/articles/container-registry-and-runtime#unsupported-dockerfile-commands
Heroku Container Registry allows you to deploy your Docker-based app to Heroku. Both Common Runtime and Private Spaces are supported.
何かクラッシュするバグを仕込んでしまったぽい…
これ、テストとか頑張れば書けるのかな…
Avatar
Kishikawa Katsumi 19-Apr-18 08:47 AM
私もややこしくなってきたので、1メソッドで書き下していたのを分割して、意図しない影響を与えてないかを確認する正常系のテストを書こうと思ってます。それは難しくないはず。
その次に書けたら意地悪な投稿でも問題が起きないようにある程度異常系のケースを書いて、って感じですね。
それ以上は今のところ何かあったら再起動でいいので諦めていいんじゃないですか。
Avatar
norio_nomura 19-Apr-18 08:52 AM
まあ、そうですね。
Avatar
Kishikawa Katsumi 19-Apr-18 04:11 PM
@swiftbot
import Foundation print("Hello world!!")
(edited)
🛠 2
Avatar
swiftbot BOT 19-Apr-18 04:11 PM
Swift version 4.1 (swift-4.1-RELEASE)
(edited)
Hello world!!
(edited)
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Hello world!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Hello world!!
Avatar
Kishikawa Katsumi 19-Apr-18 04:13 PM
のむらさんのアイデアをいただいて、編集できるようにした。 あと、masterのツールチェーンで再ビルドするボタン( 🛠 のリアクション)付けてみた。
Avatar
swiftbot BOT 19-Apr-18 11:21 PM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Hello world!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Hello world!!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Hello world!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Hello world!!
Avatar
norio_nomura 19-Apr-18 11:21 PM
リアクションの数が実行回数に反映されてる?
😅 1
Avatar
omochimetaru 20-Apr-18 02:01 AM
@swiftbot
print("a!")
🛠 5
Avatar
swiftbot BOT 20-Apr-18 02:01 AM
Swift version 4.1 (swift-4.1-RELEASE)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
omochimetaru 20-Apr-18 02:01 AM
うおおw
絵文字のセンスも良いw
Avatar
hiragram 20-Apr-18 02:02 AM
ディスコの開発環境化が進んでる
Avatar
swiftbot BOT 20-Apr-18 02:02 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
d_date 20-Apr-18 02:02 AM
すご
Avatar
swiftbot BOT 20-Apr-18 02:03 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
d_date 20-Apr-18 02:03 AM
めっちゃでてくるw
Avatar
omochimetaru 20-Apr-18 02:03 AM
なんか多いな?w
Avatar
Kishikawa Katsumi 20-Apr-18 02:03 AM
バグがあるな。。。
Avatar
hiragram 20-Apr-18 02:03 AM
あ 連打してしまった
ごめんなさい
Avatar
swiftbot BOT 20-Apr-18 02:04 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:04 AM
a!
Avatar
swiftbot BOT 20-Apr-18 02:04 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
Kishikawa Katsumi 20-Apr-18 02:04 AM
なんか不具合があるのとは別に、元々の投稿者の人だけが再ビルド反応するようにしていいかも。 (edited)
Avatar
swiftbot BOT 20-Apr-18 02:04 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:04 AM
多分その方がいいですね
Avatar
swiftbot BOT 20-Apr-18 02:05 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
Kishikawa Katsumi 20-Apr-18 02:05 AM
その処理だけ急いで入れるか。
Avatar
hiragram 20-Apr-18 02:05 AM
(ていうかそうなると思ってめちゃ連打してしまった)
Avatar
swiftbot BOT 20-Apr-18 02:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:05 AM
まだくるのか
Avatar
swiftbot BOT 20-Apr-18 02:05 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:05 AM
さすがにこんなに押してないぞw
Avatar
swiftbot BOT 20-Apr-18 02:05 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
omochimetaru 20-Apr-18 02:05 AM
大丈夫かこれw
Avatar
swiftbot BOT 20-Apr-18 02:05 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:05 AM
なんかとまんなくなってそう
Avatar
omochimetaru 20-Apr-18 02:05 AM
ww
Avatar
swiftbot BOT 20-Apr-18 02:05 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:06 AM
botが自殺しそうなコード投げたらクラッシュして止まりそう
とまらないかな
Avatar
swiftbot BOT 20-Apr-18 02:06 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
Kishikawa Katsumi 20-Apr-18 02:06 AM
止めてみます。
Avatar
swiftbot BOT 20-Apr-18 02:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
d_date 20-Apr-18 02:06 AM
通知がw
Avatar
swiftbot BOT 20-Apr-18 02:06 AM
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
Avatar
hiragram 20-Apr-18 02:06 AM
@swiftbot Int?.none!
Avatar
swiftbot BOT 20-Apr-18 02:06 AM
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
a!
Avatar
hiragram 20-Apr-18 02:07 AM
とまった
Avatar
Kishikawa Katsumi 20-Apr-18 02:07 AM
再起動したから前の情報は忘れるはず。
Avatar
hiragram 20-Apr-18 02:07 AM
いちにのぽかん
Avatar
d_date 20-Apr-18 02:07 AM
(夜中に発動したら大変なことになるなw)
Avatar
Kishikawa Katsumi 20-Apr-18 02:14 AM
たぶん、他の人が押してもビルドしなくなったと思います。
回数の問題は推測だけど再ビルドはパラメータをちょっと変えて再帰的に呼び出すみたいな処理になってるので、リアクションを受けた時のコールバックのクロージャがどんどん増えてるんじゃないかと。これはちょっと設計を見直しているのでそこで直せるはず。
Avatar
masakihori 20-Apr-18 07:53 AM
@swift-4.2.4
enum Hoge: CaseIterable { case hoge, fuga, piyo } Hoge.allCases.map { print($0) }
(edited)
Avatar
norio_nomura 20-Apr-18 07:55 AM
あ、編集してメンション付け加えるのにはまだ対応してません。
対応するか。
Avatar
masakihori 20-Apr-18 07:55 AM
了解
@swift-4.2.4
enum Hoge: CaseIterable { case hoge, fuga, piyo } Hoge.allCases.forEach { print($0) }
(edited)
Avatar
swift42 BOT 20-Apr-18 07:56 AM
hoge fuga piyo
(edited)
Avatar
masakihori 20-Apr-18 07:57 AM
ほほう
Avatar
norio_nomura 20-Apr-18 12:55 PM
編集でのメンションの追加/削除、メッセージ削除をサポートしました。 @swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
(edited)
Avatar
swift42 BOT 20-Apr-18 12:56 PM
DEVELOPMENT-SNAPSHOT-2018-04-19-a
(edited)
Avatar
swift42 BOT 21-Apr-18 02:51 AM
DEVELOPMENT-SNAPSHOT-2018-04-20-a
Avatar
norio_nomura 22-Apr-18 11:23 AM
標準出力・標準エラーのサイズが大きい時、メッセージへファイル添付するのをやめて、代わりに https://www.file.io へアップロードする様に変更しました。 Discordのファイル添付はAPIから中身を変更できないため、コード編集により出力が変わっても今までは反映することが出来ませんでした。 この変更により、更新された出力へのリンクを一緒に返すことができる様になりました。 @swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
(edited)
Avatar
swift42 BOT 22-Apr-18 11:23 AM
DEVELOPMENT-SNAPSHOT-2018-04-21-a
(edited)
Avatar
swift42 BOT 23-Apr-18 12:14 AM
DEVELOPMENT-SNAPSHOT-2018-04-22-a
Avatar
norio_nomura 24-Apr-18 03:24 PM
RxSwiftをインポートできる様にしました。 @swift-4.0.3 @swift-4.1.3 @swift-4.2.4
import Foundation let versionOfRxSwift = ProcessInfo.processInfo.environment["RXSWIFT_VERSION"] ?? "" print("RxSwift version: \(versionOfRxSwift)") import RxSwift _ = Observable<String>.create { observerOfString in print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) return Disposables.create() } .subscribe { event in print(event) }
👏 2
Avatar
swift41 BOT 24-Apr-18 03:24 PM
RxSwift version: 4.1.2 Observable created next(😉) completed
Avatar
swift42 BOT 24-Apr-18 03:24 PM
RxSwift version: 4.1.2 Observable created next(😉) completed
Avatar
swift40 BOT 24-Apr-18 03:24 PM
RxSwift version: 4.1.2 Observable created next(😉) completed
Avatar
Kishikawa Katsumi 24-Apr-18 03:24 PM
素晴らしい。
Avatar
norio_nomura 24-Apr-18 03:29 PM
libRxSwift.soを作るのにPackage.swift内でlibrary typeをdynamicにしなくても、
swift build --target RxSwift -Xswiftc -emit-library -Xswiftc -o -Xswiftc `swift build --show-bin-path`/libRxSwift.so
とすれば作れることを知りました。
Avatar
tarunon 24-Apr-18 03:40 PM
これって例の最適化バグ回避してます?
試してみよう
Avatar
norio_nomura 24-Apr-18 03:44 PM
RxSwift自体はdebugビルドされてます。
Avatar
tarunon 24-Apr-18 03:44 PM
おー
じゃあ心配ないすね
Avatar
omochimetaru 25-Apr-18 11:31 AM
@swiftbot
let a: UInt32 = 0x80_00_00_00 let b: UInt32 = 0x80_00_00_00 let c = a.addingReportingOverflow(b) dump(c)
(edited)
🛠 1
Avatar
swiftbot BOT 25-Apr-18 11:31 AM
Swift version 4.1 (swift-4.1-RELEASE)
(edited)
▿ (2 elements) - partialValue: 0 - overflow: true
Avatar
omochimetaru 25-Apr-18 11:32 AM
@swiftbot
let a: UInt32 = 0x80_00_00_00 let b: UInt32 = 0x7F_FF_FF_FF let c = a.addingReportingOverflow(b) dump(c)
🛠 1
Avatar
swiftbot BOT 25-Apr-18 11:32 AM
Swift version 4.1 (swift-4.1-RELEASE)
▿ (2 elements) - partialValue: 4294967295 - overflow: false
Avatar
kenmaz 27-Apr-18 01:19 AM
@swift-tensorflow
import TensorFlow
Avatar
swiftTensorflow BOT 27-Apr-18 01:19 AM
no output
Avatar
norio_nomura 27-Apr-18 02:13 AM
import Pythonは通るけど、動かない? @swift-tensorflow
import TensorFlow import Python // NumPy example: let np = Python.import("numpy") // import numpy as np let a = np.arange(15).reshape(3, 5) // a = np.arange(15).reshape(3, 5) let b = np.array([6, 7, 8]) // b = np.array([6, 7, 8])
Avatar
swiftTensorflow BOT 27-Apr-18 02:13 AM
exit status: 1 with stderr:
main.swift:5:18: error: cannot call value of non-function type 'PyValue' let a = np.arange(15).reshape(3, 5) // a = np.arange(15).reshape(3, 5) ~~~~~~~~~^ main.swift:6:17: error: cannot call value of non-function type 'PyValue' let b = np.array([6, 7, 8]) // b = np.array([6, 7, 8]) ~~~~~~~~^
Avatar
omochimetaru 27-Apr-18 02:13 AM
numpyがインストールされてないのでは?
python環境の方に。
Avatar
norio_nomura 27-Apr-18 02:14 AM
Avatar
omochimetaru 27-Apr-18 02:15 AM
ああ、なるほど、インストール済みのイメージなんですね。
Avatar
norio_nomura 27-Apr-18 02:15 AM
サンプルコードで動作確認してて、足りてなかったものは入れる様にしました。 (edited)
Avatar
kenmaz 27-Apr-18 07:39 AM
np.arange.call(with: 15) じゃないと動かないみたいですね
Avatar
omochimetaru 27-Apr-18 07:39 AM
なるほど。
Avatar
rintaro 27-Apr-18 08:34 AM
@swiftbot
import Foundation @objc protocol Hoge { func foobarbaz() } var x: AnyObject = "hoge" as NSString x.foobarbaz()
(edited)
🛠 2
Avatar
swiftbot BOT 27-Apr-18 08:34 AM
Swift version 4.1 (swift-4.1-RELEASE)
(edited)
<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Program used external function 'sel_registerName' which could not be resolved! /usr/bin/swift[0x3f24d54] /usr/bin/swift[0x3f25096] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f12ac409390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f12aab48428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f12aab4a02a] /usr/bin/swift[0x4c3f75] /usr/bin/swift[0x3eb851f] /usr/bin/swift[0xffeddb] /usr/bin/swift[0xffd626] /usr/bin/swift[0xfead79] /usr/bin/swift[0x4d8e48] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f12aab33830] /usr/bin/swift[0x475179] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -I /usr/lib/swift/clang/include/ -I /vendor/SwiftyMath/.build/release/ -I /vendor/swift-package-libbsd/ -module-name main -ldSwiftyMath Aborted (core dumped)
(edited)
swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a Swift version 4.2-dev (LLVM d14a2b25f2, Clang da1edea3f7, Swift ac061632b2)
/usercode/main.swift:7:22: error: 'Int' is not convertible to 'AnyObject'; did you mean to use 'as!' to force downcast? var x: AnyObject = 1 as AnyObject ~~^~~~~~~~~~~~ as!
Avatar
rintaro 27-Apr-18 08:37 AM
AnyObject の何でもメソッド呼べちゃう性を Linux で試して見たかっただけなのですが、どこで落ちているのか分からないですねw
Avatar
Kishikawa Katsumi 27-Apr-18 08:39 AM
のむらさんの方でやったらどうですかね?私のやつもバックトレースの改善とかいろいろやろうと思うのですが、最近時間取れてなくて。
👌 1
Avatar
rintaro 27-Apr-18 08:40 AM
@swift-4.1.3
import Foundation @objc protocol Hoge { func foobarbaz() } var x: AnyObject = "hoge" as NSString x.foobarbaz()
(edited)
Avatar
swift41 BOT 27-Apr-18 08:40 AM
stderr:
<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Program used external function 'sel_registerName' which could not be resolved! #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007f3b0201f390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f3b0075e428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f3b0076002a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00000000004c3f75 (/usr/bin/swift+0x4c3f75) #6 0x0000000003eb851f llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/bin/swift+0x3eb851f) #7 0x0000000000ffeddb llvm::RuntimeDyldImpl::resolveExternalSymbols() (/usr/bin/swift+0xffeddb) #8 0x0000000000ffd626 llvm::RuntimeDyldImpl::resolveRelocations() (/usr/bin/swift+0xffd626) #9 0x0000000000fead79 llvm::MCJIT::finalizeObject() (/usr/bin/swift+0xfead79) #10 0x00000000004d8e48 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) (/usr/bin/swift+0x4d8e48) #11 0x00000000004c35d3 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4c35d3) #12 0x00000000004beecc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4beecc) #13 0x00000000004778c4 main (/usr/bin/swift+0x4778c4) #14 0x00007f3b00749830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #15 0x0000000000475179 _start (/usr/bin/swift+0x475179) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret main.sw
(edited)
Avatar
norio_nomura 27-Apr-18 12:25 PM
demangle復活 @swift-4.1.3 demangle _T0s19preconditionFailures5NeverOSSyXKs12StaticStringV4fileSu4linetFfA
Avatar
swift41 BOT 27-Apr-18 12:25 PM
_T0s19preconditionFailures5NeverOSSyXK_s12StaticStringV4fileSu4linetFfA_ ---> default argument 0 of Swift.preconditionFailure(@autoclosure () -> Swift.String, file: Swift.StaticString, line: Swift.UInt) -> Swift.Never
Avatar
rintaro 27-Apr-18 12:41 PM
@swift-4.1.3 demangle -simplified _T0s19preconditionFailures5NeverOSSyXKs12StaticStringV4fileSu4linetFfA (edited)
Avatar
swift41 BOT 27-Apr-18 12:41 PM
_T0s19preconditionFailures5NeverOSSyXK_s12StaticStringV4fileSu4linetFfA_ ---> default argument 0 of preconditionFailure(_:file:line:)
(edited)
Avatar
norio_nomura 27-Apr-18 12:59 PM
botで残る課題は、機能としてはリプライ情報の永続化くらいかな。
運用はスナップショットの自動更新。
あ、botへDMも解放したいな。
❤ 1
Avatar
norio_nomura 27-Apr-18 02:39 PM
botへのDMを解放しました。 DMでは、メンションが含まれていなくても返事を返しますが、コンパイラオプションを渡す場合にはメンションに続けて記述してください。
[@swift41 [SWIFT_OPTIONS]] `​`​`​ [Swift Code] `​`​`​
Avatar
norio_nomura 02-May-18 08:34 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
(edited)
Avatar
swift42 BOT 02-May-18 08:34 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
norio_nomura 02-May-18 09:41 AM
swiftmain.swift としてコードを渡して実行させる方式だと、シグナルハンドラを設定しても呼ばれないな。
Avatar
Kishikawa Katsumi 02-May-18 09:56 AM
コンパイルして実行だと多少元のコードに手を加えないといけないのがちょっと面倒なんですよね。
Avatar
norio_nomura 02-May-18 02:10 PM
そしてボットのクラッシュログは出なかった…
Avatar
swift42 BOT 03-May-18 09:44 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
Avatar
kenmaz 03-May-18 04:36 PM
@swift-4.0.3
import Foundation func decimalNumberWithDouble(double: Double) -> NSDecimalNumber { let number = double as NSNumber return NSDecimalNumber(string: number.stringValue) } var i = decimalNumberWithDouble(double: 0.0) let limit = decimalNumberWithDouble(double: 1.1) let target = decimalNumberWithDouble(double: 1.0) while i.compare(limit) == ComparisonResult.orderedAscending { let add = decimalNumberWithDouble(double: 0.01) i = i.adding(add) print(i, i == target) if i == target { print("####called this line####") } } print("fin")
Avatar
swift40 BOT 03-May-18 04:36 PM
exit status: 1 with stderr:
main.swift:5:18: error: cannot convert value of type 'Double' to type 'NSNumber' in coercion let number = double as NSNumber ^~~~~~
Avatar
d_date 04-May-18 05:25 AM
@swift-4.1.3 -Onone
import Foundation protocol P { func hoge() } class Q {} extension Q: P { @objc func hoge() { print("q: hoge") } } class R: Q { override func hoge() { super.hoge() print("r: hoge") } } let q = Q() let r = R() q.hoge() r.hoge()
Avatar
swift41 BOT 04-May-18 05:25 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/IRGen/GenClass.cpp:2211: llvm::Constant *swift::irgen::emitCategoryData(swift::irgen::IRGenModule &, swift::ExtensionDecl *): Assertion `IGM.ObjCInterop && "emitting RO-data outside of interop mode"' failed. #0 0x0000000003f24d54 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f24d54) #1 0x0000000003f25096 SignalHandler(int) (/usr/bin/swift+0x3f25096) #2 0x00007f19216ff390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f191fe3e428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f191fe4002a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f191fe36bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #6 0x00007f191fe36c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #7 0x000000000066766e swift::irgen::emitCategoryData(swift::irgen::IRGenModule&, swift::ExtensionDecl*) (/usr/bin/swift+0x66766e) #8 0x00000000004e8dc1 swift::irgen::IRGenModule::emitExtension(swift::ExtensionDecl*) (/usr/bin/swift+0x4e8dc1) #9 0x00000000004e0555 swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&, unsigned int) (/usr/bin/swift+0x4e0555) #10 0x00000000005ad7d6 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) (/usr/bin/swift+0x5ad7d6) #11 0x00000000005abf9d swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, llvm::GlobalVariable**) (/usr/bin/swift+0x5abf9d) #12 0x00000000004d878b swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
Avatar
d_date 04-May-18 05:26 AM
あ、そっかそりゃ無理だ
Avatar
Kishikawa Katsumi 05-May-18 12:36 AM
@swiftbot !docker build --no-cache=true --rm=true --tag=kishikawakatsumi/swift:2018-05-02-a . --build-arg SWIFT_BRANCH=swift-4.2-branch --build-arg SWIFT_VERSION=swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
@swiftbot !docker build --no-cache=true --rm=true --tag=kishikawakatsumi/swift:2018-05-02-a . --build-arg SWIFT_BRANCH=swift-4.2-branch --build-arg SWIFT_VERSION=swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
@swiftbot versions
Avatar
swiftbot BOT 05-May-18 12:43 AM
2018-04-25-a 2018-05-02-a 3.0.1 3.0.2 3.1 3.1.1 4.0 4.0.2 4.0.3 4.1
Avatar
swift41 BOT 05-May-18 04:25 AM
4.1.1-RELEASE
Avatar
Kishikawa Katsumi 05-May-18 04:26 AM
@swiftbot !docker build --no-cache=true --rm=true --tag=kishikawakatsumi/swift:4.1.1 . --build-arg SWIFT_BRANCH=swift-4.1.1-release --build-arg SWIFT_VERSION=swift-4.1.1-RELEASE
Avatar
swiftbot BOT 05-May-18 04:28 AM
```undefined Sending build context to Docker daemon 88.85MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 3fd6e4adc20e Removing intermediate container 3fd6e4adc20e ---> 851cf3e30ed9 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 40c790c23ab1 Removing intermediate container 40c790c23ab1 ---> 5051d0941e8f Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in 9413e8e47de6 Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [612 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:7 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:8 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [436 kB] Get:10 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3755 B] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB] Get:14 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB] Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [255 kB] Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [991 kB] Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB] Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [804 kB] Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.8 kB] Get:20 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5157 B] Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [8075 B] Fetched 25.2 MB in 5s (4932 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: binfmt-support binutils build-essential bzip2 ca-certificates cpp cpp-5 dpkg-dev fakeroot file g++ g++-5 gcc gcc-5 git-man icu-devtools ifupdown iproute2 isc-dhcp-client isc-dhcp-common krb5-locales less libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libasn1-8-heimdal libatm1 libatomic1 libbsd-dev libbsd0 libc-dev-bin libcc1-0 libcilkrts5 libclang-common-3.8-dev libclang1-3.8 libcurl3 libcurl3-gnutls libdns-export162 libdpkg-perl libedit2 liberror-perl libexpat1 libfakeroot libffi-dev libffi6 libfile-fcntllock-perl libgcc-5-dev libgdbm3 libglib2.0-0 libglib2.0-data libgmp10 libgnutls30 libgomp1 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libicu55 libidn11 libisc-export160 libisl15 libitm1 libjsoncpp1 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3
libkrb5support0 libldap-2.4-2 libllvm3.8 liblsan0 libmagic1 libmnl0 libmpc3 libmpfr4 libmpx0 libnettle6 libobjc-5-dev libobjc4 libp11-kit0 libperl5.22 libpipeline1 libpopt0 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libquadmath0 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl-doc libssl1.0.0 libstdc++-5-dev libtasn1-6 libtinfo-dev libtsan0 libubsan0 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 libxtables11 linux-libc-dev llvm-3.8 llvm-3.8-dev llvm-3.8-runtime manpages manpages-dev mime-support netbase openssh-client openssl patch perl perl-base perl-modules-5.22 python python-minimal python2.7 python2.7-minimal rename rsync sgml-base shared-mime-info xauth xdg-user-dirs xml-core xz-utils zlib1g-dev Suggested packages: binutils-doc bzip2-doc gnustep gnustep-devel clang-3.8-doc cpp-doc gcc-5-locales debian-keyring g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-5-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn ppp rdnssd iproute2-doc resolvconf avahi-autoipd isc-dhcp-client-ddns apparmor glibc-doc libcurl4-doc libcurl3-dbg libidn11-dev libkrb5-dev libldap2-dev librtmp-dev gnutls-bin krb5-doc krb5-user icu-doc libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libstdc++-5-doc llvm-3.8-doc make-doc man-browser ssh-askpass libpam-ssh keychain monkeysphere ed diffutils-doc perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl python-doc
python-tk python2.7-doc openssh-server sgml-base-doc debhelper The following NEW packages will be installed: binfmt-support binutils build-essential bzip2 ca-certificates clang-3.8 cpp cpp-5 curl dpkg-dev fakeroot file g++ g++-5 gcc gcc-5 git git-man icu-devtools ifupdown iproute2 isc-dhcp-client isc-dhcp-common krb5-locales less libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libasn1-8-heimdal libatm1 libatomic1 libbsd-dev libbsd0 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libclang-common-3.8-dev libclang1-3.8 libcurl3 libcurl3-gnutls libcurl4-openssl-dev libdns-export162 libdpkg-perl libedit-dev libedit2 liberror-perl libexpat1 libfakeroot libffi-dev libffi6 libfile-fcntllock-perl libgcc-5-dev libgdbm3 libglib2.0-0 libglib2.0-data libgmp10 libgnutls30 libgomp1 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libicu-dev libicu55 libidn11 libisc-export160 libisl15 libitm1 libjsoncpp1 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libllvm3.8 liblsan0 libmagic1 libmnl0 libmpc3 libmpfr4 libmpx0 libnettle6 libobjc-5-dev libobjc4 libp11-kit0 libperl5.22 libpipeline1 libpopt0 libpython-stdlib libpython2.7 libpython2.7-minimal libpython2.7-stdlib libquadmath0 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl-dev libssl-doc libssl1.0.0 libstdc++-5-dev libtasn1-6 libtinfo-dev libtsan0 libubsan0 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxml2 libxmuu1 libxtables11 linux-libc-dev llvm-3.8 llvm-3.8-dev llvm-3.8-runtime make manpages manpages-dev mime-support netbase openssh-client openssl patch perl perl-modules-5.22 pkg-config python python-minimal python2.7 python2.7-minimal rename rsync sgml-base
shared-mime-info tzdata xauth xdg-user-dirs xml-core xz-utils zlib1g-dev The following packages will be upgraded: perl-base 1 upgraded, 152 newly installed, 0 to remove and 13 not upgraded. Need to get 144 MB of archives. After this operation, 654 MB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 perl-base amd64 5.22.1-9ubuntu0.3 [1286 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 libatm1 amd64 1:2.5.1-1.5 [24.2 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmnl0 amd64 1.0.3-5 [12.0 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 libpopt0 amd64 1.16-10 [26.0 kB] Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgdbm3 amd64 1.8.3-13.1 [16.9 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxau6 amd64 1:1.0.8-1 [8376 B] Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxdmcp6 amd64 1:1.1.2-1.1 [11.0 kB] Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxcb1 amd64 1.11.1-1ubuntu1 [40.0 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial/main amd64 libx11-data all 2:1.6.3-1ubuntu2 [113 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/main amd64 libx11-6 amd64 2:1.6.3-1ubuntu2 [571 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxext6 amd64 2:1.3.3-1 [29.4 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/main amd64 sgml-base all 1.26+nmu4ubuntu1 [12.5 kB] Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 perl-modules-5.22 all 5.22.1-9ubuntu0.3 [2646 kB] Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libperl5.22 amd64 5.22.1-9ubuntu0.3 [3402 kB] Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 perl amd64 5.22.1-9ubuntu0.3 [237 kB] Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [340 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [1261 kB] Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-minimal amd64 2.7.12-1~16.04 [28.1 kB] Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 mime-support all 3.59ubuntu1 [31.0 kB] Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libexpat1 amd64 2.1.0-7ubuntu0.16.04.3 [71.2 kB] Get:21 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi6 amd64 3.2.1-4 [17.8 kB] Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsqlite3-0 amd64 3.11.0-1ubuntu1 [396 kB] Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl1.0.0 amd64 1.0.2g-1ubuntu4.12 [1085 kB] Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.3 [1880 kB] Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.3 [224 kB] Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython-stdlib amd64 2.7.12-1~16.04 [7768 B] Get:27 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python amd64 2.7.12-1~16.04 [137 kB] Get:28 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgmp10 amd64 2:6.1.0+dfsg-2 [240 kB] Get:29 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpfr4 amd64 3.1.4-1 [191 kB] Get:30 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB] Get:31 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 tzdata all 2017c-0ubuntu0.16.04 [166 kB] Get:32 http://archive.ubuntu.com/ubuntu xenial/main amd64 bzip2 amd64 1.0.6-8 [32.7 kB] Get:33 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmagic1 amd64 1:5.25-2ubuntu1 [216 kB] Get:34 http://archive.ubuntu.com/ubuntu xenial/main amd64 file amd64 1:5.25-2ubuntu1 [21.2 kB]
Get:35 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 iproute2 amd64 4.3.0-1ubuntu3.16.04.3 [522 kB] Get:36 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ifupdown amd64 0.8.10ubuntu1.3 [55.0 kB] Get:37 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libisc-export160 amd64 1:9.10.3.dfsg.P4-8ubuntu1.10 [153 kB] Get:38 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdns-export162 amd64 1:9.10.3.dfsg.P4-8ubuntu1.10 [666 kB] Get:39 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 isc-dhcp-client amd64 4.3.3-5ubuntu12.10 [224 kB] Get:40 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 isc-dhcp-common amd64 4.3.3-5ubuntu12.10 [105 kB] Get:41 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 less amd64 481-2.1ubuntu0.2 [110 kB] Get:42 http://archive.ubuntu.com/ubuntu xenial/main amd64 libbsd0 amd64 0.8.2-1 [41.7 kB] Get:43 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libnettle6 amd64 3.2-1ubuntu0.16.04.1 [93.5 kB] Get:44 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhogweed4 amd64 3.2-1ubuntu0.16.04.1 [136 kB] Get:45 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libidn11 amd64 1.32-3ubuntu1.2 [46.5 kB] Get:46 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libp11-kit0 amd64 0.23.2-5~ubuntu16.04.1 [105 kB] Get:47 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtasn1-6 amd64 4.7-3ubuntu0.16.04.3 [43.5 kB] Get:48 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgnutls30 amd64 3.4.10-4ubuntu1.4 [548 kB] Get:49 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxtables11 amd64 1.6.0-2ubuntu3 [27.2 kB] Get:50 http://archive.ubuntu.com/ubuntu xenial/main amd64 netbase all 5.3 [12.9 kB] Get:51 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssl amd64 1.0.2g-1ubuntu4.12 [492 kB]
Get:52 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ca-certificates all 20170717~16.04.1 [168 kB] Get:53 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 krb5-locales all 1.13.2+dfsg-5ubuntu2 [13.2 kB] Get:54 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libroken18-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [41.4 kB] Get:55 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasn1-8-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [174 kB] Get:56 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5support0 amd64 1.13.2+dfsg-5ubuntu2 [30.8 kB] Get:57 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libk5crypto3 amd64 1.13.2+dfsg-5ubuntu2 [81.2 kB] Get:58 http://archive.ubuntu.com/ubuntu xenial/main amd64 libkeyutils1 amd64 1.5.9-8ubuntu1 [9904 B] Get:59 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5-3 amd64 1.13.2+dfsg-5ubuntu2 [273 kB] Get:60 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssapi-krb5-2 amd64 1.13.2+dfsg-5ubuntu2 [120 kB] Get:61 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhcrypto4-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [85.0 kB] Get:62 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libheimbase1-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [29.3 kB] Get:63 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libwind0-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [47.8 kB] Get:64 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libhx509-5-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [107 kB] Get:65 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkrb5-26-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [202 kB] Get:66 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libheimntlm0-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [15.1 kB]
Get:67 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssapi3-heimdal amd64 1.7~git20150920+dfsg-4ubuntu1.16.04.1 [96.1 kB] Get:68 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-modules-db amd64 2.1.26.dfsg1-14build1 [14.5 kB] Get:69 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-2 amd64 2.1.26.dfsg1-14build1 [48.7 kB] Get:70 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libldap-2.4-2 amd64 2.4.42+dfsg-2ubuntu3.2 [160 kB] Get:71 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 librtmp1 amd64 2.4+20151223.gitfa8646d-1ubuntu0.1 [54.4 kB] Get:72 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3-gnutls amd64 7.47.0-1ubuntu2.7 [185 kB] Get:73 http://archive.ubuntu.com/ubuntu xenial/main amd64 libedit2 amd64 3.1-20150325-1ubuntu2 [76.5 kB] Get:74 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libglib2.0-0 amd64 2.48.2-0ubuntu1 [1119 kB] Get:75 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libglib2.0-data all 2.48.2-0ubuntu1 [132 kB] Get:76 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libicu55 amd64 55.1-7ubuntu0.4 [7646 kB] Get:77 http://archive.ubuntu.com/ubuntu xenial/main amd64 libpipeline1 amd64 1.4.1-2 [24.6 kB] Get:78 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsasl2-modules amd64 2.1.26.dfsg1-14build1 [47.5 kB] Get:79 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libxml2 amd64 2.9.3+dfsg1-1ubuntu0.5 [697 kB] Get:80 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxmuu1 amd64 2:1.1.2-2 [9674 B] Get:81 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages all 4.04-2 [1087 kB] Get:82 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.4 [589 kB] Get:83 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 rsync amd64 3.1.1-3ubuntu1.2 [329 kB]
Get:84 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 shared-mime-info amd64 1.5-2ubuntu0.1 [405 kB] Get:85 http://archive.ubuntu.com/ubuntu xenial/main amd64 xauth amd64 1:1.0.9-1ubuntu2 [22.7 kB] Get:86 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 xdg-user-dirs amd64 0.15-2ubuntu6.16.04.1 [61.8 kB] Get:87 http://archive.ubuntu.com/ubuntu xenial/main amd64 xml-core all 0.13+nmu2 [23.3 kB] Get:88 http://archive.ubuntu.com/ubuntu xenial/main amd64 binfmt-support amd64 2.1.6-1 [50.7 kB] Get:89 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.6 [2311 kB] Get:90 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu10 [68.7 kB] Get:91 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-122.146 [850 kB] Get:92 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu10 [2079 kB] Get:93 http://archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB] Get:94 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.9 [7685 kB] Get:95 http://archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB] Get:96 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.9 [38.8 kB] Get:97 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.9 [55.0 kB] Get:98 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.9 [27.4 kB] Get:99 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.9 [8882 B] Get:100 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.9 [264 kB] Get:101 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.9 [105 kB]
Get:102 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.9 [244 kB] Get:103 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.9 [95.2 kB] Get:104 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.9 [40.1 kB] Get:105 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.9 [9774 B] Get:106 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.9 [131 kB] Get:107 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [2242 kB] Get:108 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.9 [8650 kB] Get:109 http://archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5244 B] Get:110 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [1427 kB] Get:111 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 g++-5 amd64 5.4.0-6ubuntu1~16.04.9 [8333 kB] Get:112 http://archive.ubuntu.com/ubuntu xenial/main amd64 g++ amd64 4:5.3.1-1ubuntu1 [1504 B] Get:113 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB] Get:114 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdpkg-perl all 1.18.4ubuntu1.4 [195 kB] Get:115 http://archive.ubuntu.com/ubuntu xenial/main amd64 xz-utils amd64 5.1.1alpha+20120614-2ubuntu2 [78.8 kB] Get:116 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 patch amd64 2.7.5-1ubuntu0.16.04.1 [90.5 kB] Get:117 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 dpkg-dev all 1.18.4ubuntu1.4 [584 kB] Get:118 http://archive.ubuntu.com/ubuntu xenial/main amd64 build-essential amd64 12.1ubuntu2 [4758 B]
Get:119 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libllvm3.8 amd64 1:3.8-2ubuntu4 [10.3 MB] Get:120 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libobjc4 amd64 5.4.0-6ubuntu1~16.04.9 [111 kB] Get:121 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libobjc-5-dev amd64 5.4.0-6ubuntu1~16.04.9 [381 kB] Get:122 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libclang1-3.8 amd64 1:3.8-2ubuntu4 [4139 kB] Get:123 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 libclang-common-3.8-dev amd64 1:3.8-2ubuntu4 [1167 kB] Get:124 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 clang-3.8 amd64 1:3.8-2ubuntu4 [21.5 MB] Get:125 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 curl amd64 7.47.0-1ubuntu2.7 [138 kB] Get:126 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfakeroot amd64 1.20.2-1ubuntu1 [25.5 kB] Get:127 http://archive.ubuntu.com/ubuntu xenial/main amd64 fakeroot amd64 1.20.2-1ubuntu1 [61.8 kB] Get:128 http://archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB] Get:129 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.3 [736 kB] Get:130 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.3 [3102 kB] Get:131 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 icu-devtools amd64 55.1-7ubuntu0.4 [166 kB] Get:132 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB] Get:133 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4build1 [11.0 kB] Get:134 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB] Get:135 http://archive.ubuntu.com/ubuntu xenial/main amd64 libbsd-dev amd64 0.8.2-1 [134 kB] Get:136 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.7 [187 kB]
Get:137 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl4-openssl-dev amd64 7.47.0-1ubuntu2.7 [262 kB] Get:138 http://archive.ubuntu.com/ubuntu xenial/main amd64 libtinfo-dev amd64 6.0+20160213-1ubuntu1 [77.4 kB] Get:139 http://archive.ubuntu.com/ubuntu xenial/main amd64 libedit-dev amd64 3.1-20150325-1ubuntu2 [92.6 kB] Get:140 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfile-fcntllock-perl amd64 0.22-3 [32.0 kB] Get:141 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libicu-dev amd64 55.1-7ubuntu0.4 [8566 kB] Get:142 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7 amd64 2.7.12-1ubuntu0~16.04.3 [1070 kB] Get:143 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB] Get:144 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-dev amd64 1.0.2g-1ubuntu4.12 [1343 kB] Get:145 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-doc all 1.0.2g-1ubuntu4.12 [1079 kB] Get:146 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 llvm-3.8-runtime amd64 1:3.8-2ubuntu4 [72.3 kB] Get:147 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 llvm-3.8 amd64 1:3.8-2ubuntu4 [1524 kB] Get:148 http://archive.ubuntu.com/ubuntu xenial/main amd64 libjsoncpp1 amd64 1.7.2-1 [73.0 kB] Get:149 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi-dev amd64 3.2.1-4 [161 kB] Get:150 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 llvm-3.8-dev amd64 1:3.8-2ubuntu4 [16.7 MB] Get:151 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages-dev all 4.04-2 [2048 kB] Get:152 http://archive.ubuntu.com/ubuntu xenial/main amd64 pkg-config amd64 0.29.1-0ubuntu1 [45.0 kB] Get:153 http://archive.ubuntu.com/ubuntu xenial/main amd64 rename all 0.20-4 [12.0 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 144 MB in 17s (8332 kB/s)
(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 4768 files and directories currently installed.) Preparing to unpack .../perl-base_5.22.1-9ubuntu0.3_amd64.deb ... Unpacking perl-base (5.22.1-9ubuntu0.3) over (5.22.1-9ubuntu0.2) ... Setting up perl-base (5.22.1-9ubuntu0.3) ... Selecting previously unselected package libatm1:amd64. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 4768 files and directories currently installed.) Preparing to unpack .../libatm1_1%3a2.5.1-1.5_amd64.deb ... Unpacking libatm1:amd64 (1:2.5.1-1.5) ... Selecting previously unselected package libmnl0:amd64. Preparing to unpack .../libmnl0_1.0.3-5_amd64.deb ... Unpacking libmnl0:amd64 (1.0.3-5) ... Selecting previously unselected package libpopt0:amd64. Preparing to unpack .../libpopt0_1.16-10_amd64.deb ... Unpacking libpopt0:amd64 (1.16-10) ... Selecting previously unselected package libgdbm3:amd64.
Preparing to unpack .../libgdbm3_1.8.3-13.1_amd64.deb ... Unpacking libgdbm3:amd64 (1.8.3-13.1) ... Selecting previously unselected package libxau6:amd64. Preparing to unpack .../libxau6_1%3a1.0.8-1_amd64.deb ... Unpacking libxau6:amd64 (1:1.0.8-1) ... Selecting previously unselected package libxdmcp6:amd64. Preparing to unpack .../libxdmcp6_1%3a1.1.2-1.1_amd64.deb ... Unpacking libxdmcp6:amd64 (1:1.1.2-1.1) ... Selecting previously unselected package libxcb1:amd64. Preparing to unpack .../libxcb1_1.11.1-1ubuntu1_amd64.deb ... Unpacking libxcb1:amd64 (1.11.1-1ubuntu1) ... Selecting previously unselected package libx11-data. Preparing to unpack .../libx11-data_2%3a1.6.3-1ubuntu2_all.deb ... Unpacking libx11-data (2:1.6.3-1ubuntu2) ... Selecting previously unselected package libx11-6:amd64. Preparing to unpack .../libx11-6_2%3a1.6.3-1ubuntu2_amd64.deb ... Unpacking libx11-6:amd64 (2:1.6.3-1ubuntu2) ... Selecting previously unselected package libxext6:amd64. Preparing to unpack .../libxext6_2%3a1.3.3-1_amd64.deb ... Unpacking libxext6:amd64 (2:1.3.3-1) ... Selecting previously unselected package sgml-base. Preparing to unpack .../sgml-base_1.26+nmu4ubuntu1_all.deb ... Unpacking sgml-base (1.26+nmu4ubuntu1) ... Selecting previously unselected package perl-modules-5.22. Preparing to unpack .../perl-modules-5.22_5.22.1-9ubuntu0.3_all.deb ... Unpacking perl-modules-5.22 (5.22.1-9ubuntu0.3) ... Selecting previously unselected package libperl5.22:amd64. Preparing to unpack .../libperl5.22_5.22.1-9ubuntu0.3_amd64.deb ... Unpacking libperl5.22:amd64 (5.22.1-9ubuntu0.3) ... Selecting previously unselected package perl. Preparing to unpack .../perl_5.22.1-9ubuntu0.3_amd64.deb ... Unpacking perl (5.22.1-9ubuntu0.3) ... Selecting previously unselected package libpython2.7-minimal:amd64. Preparing to unpack .../libpython2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package python2.7-minimal. Preparing to unpack .../python2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking python2.7-minimal (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package python-minimal. Preparing to unpack .../python-minimal_2.7.12-1~16.04_amd64.deb ... Unpacking python-minimal (2.7.12-1~16.04) ... Selecting previously unselected package mime-support. Preparing to unpack .../mime-support_3.59ubuntu1_all.deb ... Unpacking mime-support (3.59ubuntu1) ... Selecting previously unselected package libexpat1:amd64. Preparing to unpack .../libexpat1_2.1.0-7ubuntu0.16.04.3_amd64.deb ... Unpacking libexpat1:amd64 (2.1.0-7ubuntu0.16.04.3) ... Selecting previously unselected package libffi6:amd64. Preparing to unpack .../libffi6_3.2.1-4_amd64.deb ... Unpacking libffi6:amd64 (3.2.1-4) ... Selecting previously unselected package libsqlite3-0:amd64. Preparing to unpack .../libsqlite3-0_3.11.0-1ubuntu1_amd64.deb ... Unpacking libsqlite3-0:amd64 (3.11.0-1ubuntu1) ... Selecting previously unselected package libssl1.0.0:amd64. Preparing to unpack .../libssl1.0.0_1.0.2g-1ubuntu4.12_amd64.deb ... Unpacking libssl1.0.0:amd64 (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package libpython2.7-stdlib:amd64. Preparing to unpack .../libpython2.7-stdlib_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package python2.7. Preparing to unpack .../python2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking python2.7 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package libpython-stdlib:amd64. Preparing to unpack .../libpython-stdlib_2.7.12-1~16.04_amd64.deb ... Unpacking libpython-stdlib:amd64 (2.7.12-1~16.04) ... Processing triggers for libc-bin (2.23-0ubuntu10) ...
Setting up libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) ... Setting up python2.7-minimal (2.7.12-1ubuntu0~16.04.3) ... Linking and byte-compiling packages for runtime python2.7... Setting up python-minimal (2.7.12-1~16.04) ... Selecting previously unselected package python. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 7683 files and directories currently installed.) Preparing to unpack .../python_2.7.12-1~16.04_amd64.deb ... Unpacking python (2.7.12-1~16.04) ... Selecting previously unselected package libgmp10:amd64. Preparing to unpack .../libgmp10_2%3a6.1.0+dfsg-2_amd64.deb ... Unpacking libgmp10:amd64 (2:6.1.0+dfsg-2) ... Selecting previously unselected package libmpfr4:amd64. Preparing to unpack .../libmpfr4_3.1.4-1_amd64.deb ... Unpacking libmpfr4:amd64 (3.1.4-1) ... Selecting previously unselected package libmpc3:amd64. Preparing to unpack .../libmpc3_1.0.3-1_amd64.deb ... Unpacking libmpc3:amd64 (1.0.3-1) ... Selecting previously unselected package tzdata. Preparing to unpack .../tzdata_2017c-0ubuntu0.16.04_all.deb ... Unpacking tzdata (2017c-0ubuntu0.16.04) ... Selecting previously unselected package bzip2. Preparing to unpack .../bzip2_1.0.6-8_amd64.deb ... Unpacking bzip2 (1.0.6-8) ... Selecting previously unselected package libmagic1:amd64. Preparing to unpack .../libmagic1_1%3a5.25-2ubuntu1_amd64.deb ... Unpacking libmagic1:amd64 (1:5.25-2ubuntu1) ...
Selecting previously unselected package file. Preparing to unpack .../file_1%3a5.25-2ubuntu1_amd64.deb ... Unpacking file (1:5.25-2ubuntu1) ... Selecting previously unselected package iproute2. Preparing to unpack .../iproute2_4.3.0-1ubuntu3.16.04.3_amd64.deb ... Unpacking iproute2 (4.3.0-1ubuntu3.16.04.3) ... Selecting previously unselected package ifupdown. Preparing to unpack .../ifupdown_0.8.10ubuntu1.3_amd64.deb ... Unpacking ifupdown (0.8.10ubuntu1.3) ... Selecting previously unselected package libisc-export160. Preparing to unpack .../libisc-export160_1%3a9.10.3.dfsg.P4-8ubuntu1.10_amd64.deb ... Unpacking libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Selecting previously unselected package libdns-export162. Preparing to unpack .../libdns-export162_1%3a9.10.3.dfsg.P4-8ubuntu1.10_amd64.deb ... Unpacking libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Selecting previously unselected package isc-dhcp-client. Preparing to unpack .../isc-dhcp-client_4.3.3-5ubuntu12.10_amd64.deb ... Unpacking isc-dhcp-client (4.3.3-5ubuntu12.10) ... Selecting previously unselected package isc-dhcp-common. Preparing to unpack .../isc-dhcp-common_4.3.3-5ubuntu12.10_amd64.deb ... Unpacking isc-dhcp-common (4.3.3-5ubuntu12.10) ... Selecting previously unselected package less. Preparing to unpack .../less_481-2.1ubuntu0.2_amd64.deb ... Unpacking less (481-2.1ubuntu0.2) ... Selecting previously unselected package libbsd0:amd64. Preparing to unpack .../libbsd0_0.8.2-1_amd64.deb ... Unpacking libbsd0:amd64 (0.8.2-1) ... Selecting previously unselected package libnettle6:amd64. Preparing to unpack .../libnettle6_3.2-1ubuntu0.16.04.1_amd64.deb ... Unpacking libnettle6:amd64 (3.2-1ubuntu0.16.04.1) ... Selecting previously unselected package libhogweed4:amd64. Preparing to unpack .../libhogweed4_3.2-1ubuntu0.16.04.1_amd64.deb ... Unpacking libhogweed4:amd64 (3.2-1ubuntu0.16.04.1) ...
Selecting previously unselected package libidn11:amd64. Preparing to unpack .../libidn11_1.32-3ubuntu1.2_amd64.deb ... Unpacking libidn11:amd64 (1.32-3ubuntu1.2) ... Selecting previously unselected package libp11-kit0:amd64. Preparing to unpack .../libp11-kit0_0.23.2-5~ubuntu16.04.1_amd64.deb ... Unpacking libp11-kit0:amd64 (0.23.2-5~ubuntu16.04.1) ... Selecting previously unselected package libtasn1-6:amd64. Preparing to unpack .../libtasn1-6_4.7-3ubuntu0.16.04.3_amd64.deb ... Unpacking libtasn1-6:amd64 (4.7-3ubuntu0.16.04.3) ... Selecting previously unselected package libgnutls30:amd64. Preparing to unpack .../libgnutls30_3.4.10-4ubuntu1.4_amd64.deb ... Unpacking libgnutls30:amd64 (3.4.10-4ubuntu1.4) ... Selecting previously unselected package libxtables11:amd64. Preparing to unpack .../libxtables11_1.6.0-2ubuntu3_amd64.deb ... Unpacking libxtables11:amd64 (1.6.0-2ubuntu3) ... Selecting previously unselected package netbase. Preparing to unpack .../archives/netbase_5.3_all.deb ... Unpacking netbase (5.3) ... Selecting previously unselected package openssl. Preparing to unpack .../openssl_1.0.2g-1ubuntu4.12_amd64.deb ... Unpacking openssl (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package ca-certificates. Preparing to unpack .../ca-certificates_20170717~16.04.1_all.deb ... Unpacking ca-certificates (20170717~16.04.1) ... Selecting previously unselected package krb5-locales. Preparing to unpack .../krb5-locales_1.13.2+dfsg-5ubuntu2_all.deb ... Unpacking krb5-locales (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libroken18-heimdal:amd64. Preparing to unpack .../libroken18-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libroken18-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libasn1-8-heimdal:amd64.
Preparing to unpack .../libasn1-8-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libasn1-8-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libkrb5support0:amd64. Preparing to unpack .../libkrb5support0_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libkrb5support0:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libk5crypto3:amd64. Preparing to unpack .../libk5crypto3_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libk5crypto3:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libkeyutils1:amd64. Preparing to unpack .../libkeyutils1_1.5.9-8ubuntu1_amd64.deb ... Unpacking libkeyutils1:amd64 (1.5.9-8ubuntu1) ... Selecting previously unselected package libkrb5-3:amd64. Preparing to unpack .../libkrb5-3_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libkrb5-3:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libgssapi-krb5-2:amd64. Preparing to unpack .../libgssapi-krb5-2_1.13.2+dfsg-5ubuntu2_amd64.deb ... Unpacking libgssapi-krb5-2:amd64 (1.13.2+dfsg-5ubuntu2) ... Selecting previously unselected package libhcrypto4-heimdal:amd64. Preparing to unpack .../libhcrypto4-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libhcrypto4-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libheimbase1-heimdal:amd64. Preparing to unpack .../libheimbase1-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libheimbase1-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libwind0-heimdal:amd64. Preparing to unpack .../libwind0-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libwind0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libhx509-5-heimdal:amd64.
Preparing to unpack .../libhx509-5-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libhx509-5-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libkrb5-26-heimdal:amd64. Preparing to unpack .../libkrb5-26-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libkrb5-26-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libheimntlm0-heimdal:amd64. Preparing to unpack .../libheimntlm0-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libheimntlm0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libgssapi3-heimdal:amd64. Preparing to unpack .../libgssapi3-heimdal_1.7~git20150920+dfsg-4ubuntu1.16.04.1_amd64.deb ... Unpacking libgssapi3-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Selecting previously unselected package libsasl2-modules-db:amd64. Preparing to unpack .../libsasl2-modules-db_2.1.26.dfsg1-14build1_amd64.deb ... Unpacking libsasl2-modules-db:amd64 (2.1.26.dfsg1-14build1) ... Selecting previously unselected package libsasl2-2:amd64. Preparing to unpack .../libsasl2-2_2.1.26.dfsg1-14build1_amd64.deb ... Unpacking libsasl2-2:amd64 (2.1.26.dfsg1-14build1) ... Selecting previously unselected package libldap-2.4-2:amd64. Preparing to unpack .../libldap-2.4-2_2.4.42+dfsg-2ubuntu3.2_amd64.deb ... Unpacking libldap-2.4-2:amd64 (2.4.42+dfsg-2ubuntu3.2) ... Selecting previously unselected package librtmp1:amd64. Preparing to unpack .../librtmp1_2.4+20151223.gitfa8646d-1ubuntu0.1_amd64.deb ... Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d-1ubuntu0.1) ... Selecting previously unselected package libcurl3-gnutls:amd64. Preparing to unpack .../libcurl3-gnutls_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.7) ...
Selecting previously unselected package libedit2:amd64. Preparing to unpack .../libedit2_3.1-20150325-1ubuntu2_amd64.deb ... Unpacking libedit2:amd64 (3.1-20150325-1ubuntu2) ... Selecting previously unselected package libglib2.0-0:amd64. Preparing to unpack .../libglib2.0-0_2.48.2-0ubuntu1_amd64.deb ... Unpacking libglib2.0-0:amd64 (2.48.2-0ubuntu1) ... Selecting previously unselected package libglib2.0-data. Preparing to unpack .../libglib2.0-data_2.48.2-0ubuntu1_all.deb ... Unpacking libglib2.0-data (2.48.2-0ubuntu1) ... Selecting previously unselected package libicu55:amd64. Preparing to unpack .../libicu55_55.1-7ubuntu0.4_amd64.deb ... Unpacking libicu55:amd64 (55.1-7ubuntu0.4) ... Selecting previously unselected package libpipeline1:amd64. Preparing to unpack .../libpipeline1_1.4.1-2_amd64.deb ... Unpacking libpipeline1:amd64 (1.4.1-2) ... Selecting previously unselected package libsasl2-modules:amd64. Preparing to unpack .../libsasl2-modules_2.1.26.dfsg1-14build1_amd64.deb ... Unpacking libsasl2-modules:amd64 (2.1.26.dfsg1-14build1) ... Selecting previously unselected package libxml2:amd64. Preparing to unpack .../libxml2_2.9.3+dfsg1-1ubuntu0.5_amd64.deb ... Unpacking libxml2:amd64 (2.9.3+dfsg1-1ubuntu0.5) ... Selecting previously unselected package libxmuu1:amd64. Preparing to unpack .../libxmuu1_2%3a1.1.2-2_amd64.deb ... Unpacking libxmuu1:amd64 (2:1.1.2-2) ... Selecting previously unselected package manpages. Preparing to unpack .../manpages_4.04-2_all.deb ... Unpacking manpages (4.04-2) ... Selecting previously unselected package openssh-client. Preparing to unpack .../openssh-client_1%3a7.2p2-4ubuntu2.4_amd64.deb ... Unpacking openssh-client (1:7.2p2-4ubuntu2.4) ... Selecting previously unselected package rsync. Preparing to unpack .../rsync_3.1.1-3ubuntu1.2_amd64.deb ... Unpacking rsync (3.1.1-3ubuntu1.2) ... Selecting previously unselected package shared-mime-info.
Preparing to unpack .../shared-mime-info_1.5-2ubuntu0.1_amd64.deb ... Unpacking shared-mime-info (1.5-2ubuntu0.1) ... Selecting previously unselected package xauth. Preparing to unpack .../xauth_1%3a1.0.9-1ubuntu2_amd64.deb ... Unpacking xauth (1:1.0.9-1ubuntu2) ... Selecting previously unselected package xdg-user-dirs. Preparing to unpack .../xdg-user-dirs_0.15-2ubuntu6.16.04.1_amd64.deb ... Unpacking xdg-user-dirs (0.15-2ubuntu6.16.04.1) ... Selecting previously unselected package xml-core. Preparing to unpack .../xml-core_0.13+nmu2_all.deb ... Unpacking xml-core (0.13+nmu2) ... Selecting previously unselected package binfmt-support. Preparing to unpack .../binfmt-support_2.1.6-1_amd64.deb ... Unpacking binfmt-support (2.1.6-1) ... Selecting previously unselected package binutils. Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.6_amd64.deb ... Unpacking binutils (2.26.1-1ubuntu1~16.04.6) ... Selecting previously unselected package libc-dev-bin. Preparing to unpack .../libc-dev-bin_2.23-0ubuntu10_amd64.deb ... Unpacking libc-dev-bin (2.23-0ubuntu10) ... Selecting previously unselected package linux-libc-dev:amd64. Preparing to unpack .../linux-libc-dev_4.4.0-122.146_amd64.deb ... Unpacking linux-libc-dev:amd64 (4.4.0-122.146) ... Selecting previously unselected package libc6-dev:amd64. Preparing to unpack .../libc6-dev_2.23-0ubuntu10_amd64.deb ... Unpacking libc6-dev:amd64 (2.23-0ubuntu10) ... Selecting previously unselected package libisl15:amd64. Preparing to unpack .../libisl15_0.16.1-1_amd64.deb ... Unpacking libisl15:amd64 (0.16.1-1) ... Selecting previously unselected package cpp-5. Preparing to unpack .../cpp-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking cpp-5 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package cpp. Preparing to unpack .../cpp_4%3a5.3.1-1ubuntu1_amd64.deb ... Unpacking cpp (4:5.3.1-1ubuntu1) ...
Selecting previously unselected package libcc1-0:amd64. Preparing to unpack .../libcc1-0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libgomp1:amd64. Preparing to unpack .../libgomp1_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libitm1:amd64. Preparing to unpack .../libitm1_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libatomic1:amd64. Preparing to unpack .../libatomic1_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libasan2:amd64. Preparing to unpack .../libasan2_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package liblsan0:amd64. Preparing to unpack .../liblsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libtsan0:amd64. Preparing to unpack .../libtsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libubsan0:amd64. Preparing to unpack .../libubsan0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libcilkrts5:amd64. Preparing to unpack .../libcilkrts5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libmpx0:amd64. Preparing to unpack .../libmpx0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../libquadmath0_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libgcc-5-dev:amd64. Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package gcc-5. Preparing to unpack .../gcc-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking gcc-5 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package gcc. Preparing to unpack .../gcc_4%3a5.3.1-1ubuntu1_amd64.deb ... Unpacking gcc (4:5.3.1-1ubuntu1) ... Selecting previously unselected package libstdc++-5-dev:amd64. Preparing to unpack .../libstdc++-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package g++-5. Preparing to unpack .../g++-5_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking g++-5 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package g++. Preparing to unpack .../g++_4%3a5.3.1-1ubuntu1_amd64.deb ... Unpacking g++ (4:5.3.1-1ubuntu1) ... Selecting previously unselected package make. Preparing to unpack .../archives/make_4.1-6_amd64.deb ... Unpacking make (4.1-6) ... Selecting previously unselected package libdpkg-perl. Preparing to unpack .../libdpkg-perl_1.18.4ubuntu1.4_all.deb ... Unpacking libdpkg-perl (1.18.4ubuntu1.4) ... Selecting previously unselected package xz-utils. Preparing to unpack .../xz-utils_5.1.1alpha+20120614-2ubuntu2_amd64.deb ... Unpacking xz-utils (5.1.1alpha+20120614-2ubuntu2) ... Selecting previously unselected package patch. Preparing to unpack .../patch_2.7.5-1ubuntu0.16.04.1_amd64.deb ... Unpacking patch (2.7.5-1ubuntu0.16.04.1) ... Selecting previously unselected package dpkg-dev. Preparing to unpack .../dpkg-dev_1.18.4ubuntu1.4_all.deb ... Unpacking dpkg-dev (1.18.4ubuntu1.4) ...
Selecting previously unselected package build-essential. Preparing to unpack .../build-essential_12.1ubuntu2_amd64.deb ... Unpacking build-essential (12.1ubuntu2) ... Selecting previously unselected package libllvm3.8:amd64. Preparing to unpack .../libllvm3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking libllvm3.8:amd64 (1:3.8-2ubuntu4) ... Selecting previously unselected package libobjc4:amd64. Preparing to unpack .../libobjc4_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libobjc4:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libobjc-5-dev:amd64. Preparing to unpack .../libobjc-5-dev_5.4.0-6ubuntu1~16.04.9_amd64.deb ... Unpacking libobjc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Selecting previously unselected package libclang1-3.8:amd64. Preparing to unpack .../libclang1-3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking libclang1-3.8:amd64 (1:3.8-2ubuntu4) ... Selecting previously unselected package libclang-common-3.8-dev. Preparing to unpack .../libclang-common-3.8-dev_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking libclang-common-3.8-dev (1:3.8-2ubuntu4) ... Selecting previously unselected package clang-3.8. Preparing to unpack .../clang-3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking clang-3.8 (1:3.8-2ubuntu4) ... Selecting previously unselected package curl. Preparing to unpack .../curl_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking curl (7.47.0-1ubuntu2.7) ... Selecting previously unselected package libfakeroot:amd64. Preparing to unpack .../libfakeroot_1.20.2-1ubuntu1_amd64.deb ... Unpacking libfakeroot:amd64 (1.20.2-1ubuntu1) ... Selecting previously unselected package fakeroot. Preparing to unpack .../fakeroot_1.20.2-1ubuntu1_amd64.deb ... Unpacking fakeroot (1.20.2-1ubuntu1) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../liberror-perl_0.17-1.2_all.deb ... Unpacking liberror-perl (0.17-1.2) ...
Selecting previously unselected package git-man. Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.3_all.deb ... Unpacking git-man (1:2.7.4-0ubuntu1.3) ... Selecting previously unselected package git. Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.3_amd64.deb ... Unpacking git (1:2.7.4-0ubuntu1.3) ... Selecting previously unselected package icu-devtools. Preparing to unpack .../icu-devtools_55.1-7ubuntu0.4_amd64.deb ... Unpacking icu-devtools (55.1-7ubuntu0.4) ... Selecting previously unselected package libalgorithm-diff-perl. Preparing to unpack .../libalgorithm-diff-perl_1.19.03-1_all.deb ... Unpacking libalgorithm-diff-perl (1.19.03-1) ... Selecting previously unselected package libalgorithm-diff-xs-perl. Preparing to unpack .../libalgorithm-diff-xs-perl_0.04-4build1_amd64.deb ... Unpacking libalgorithm-diff-xs-perl (0.04-4build1) ... Selecting previously unselected package libalgorithm-merge-perl. Preparing to unpack .../libalgorithm-merge-perl_0.08-3_all.deb ... Unpacking libalgorithm-merge-perl (0.08-3) ... Selecting previously unselected package libbsd-dev:amd64. Preparing to unpack .../libbsd-dev_0.8.2-1_amd64.deb ... Unpacking libbsd-dev:amd64 (0.8.2-1) ... Selecting previously unselected package libcurl3:amd64. Preparing to unpack .../libcurl3_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking libcurl3:amd64 (7.47.0-1ubuntu2.7) ... Selecting previously unselected package libcurl4-openssl-dev:amd64. Preparing to unpack .../libcurl4-openssl-dev_7.47.0-1ubuntu2.7_amd64.deb ... Unpacking libcurl4-openssl-dev:amd64 (7.47.0-1ubuntu2.7) ... Selecting previously unselected package libtinfo-dev:amd64. Preparing to unpack .../libtinfo-dev_6.0+20160213-1ubuntu1_amd64.deb ... Unpacking libtinfo-dev:amd64 (6.0+20160213-1ubuntu1) ... Selecting previously unselected package libedit-dev:amd64. Preparing to unpack .../libedit-dev_3.1-20150325-1ubuntu2_amd64.deb ...
Unpacking libedit-dev:amd64 (3.1-20150325-1ubuntu2) ... Selecting previously unselected package libfile-fcntllock-perl. Preparing to unpack .../libfile-fcntllock-perl_0.22-3_amd64.deb ... Unpacking libfile-fcntllock-perl (0.22-3) ... Selecting previously unselected package libicu-dev:amd64. Preparing to unpack .../libicu-dev_55.1-7ubuntu0.4_amd64.deb ... Unpacking libicu-dev:amd64 (55.1-7ubuntu0.4) ... Selecting previously unselected package libpython2.7:amd64. Preparing to unpack .../libpython2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb ... Unpacking libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.3) ... Selecting previously unselected package zlib1g-dev:amd64. Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb ... Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ... Selecting previously unselected package libssl-dev:amd64. Preparing to unpack .../libssl-dev_1.0.2g-1ubuntu4.12_amd64.deb ... Unpacking libssl-dev:amd64 (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package libssl-doc. Preparing to unpack .../libssl-doc_1.0.2g-1ubuntu4.12_all.deb ... Unpacking libssl-doc (1.0.2g-1ubuntu4.12) ... Selecting previously unselected package llvm-3.8-runtime. Preparing to unpack .../llvm-3.8-runtime_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking llvm-3.8-runtime (1:3.8-2ubuntu4) ... Selecting previously unselected package llvm-3.8. Preparing to unpack .../llvm-3.8_1%3a3.8-2ubuntu4_amd64.deb ... Unpacking llvm-3.8 (1:3.8-2ubuntu4) ... Selecting previously unselected package libjsoncpp1:amd64. Preparing to unpack .../libjsoncpp1_1.7.2-1_amd64.deb ... Unpacking libjsoncpp1:amd64 (1.7.2-1) ... Selecting previously unselected package libffi-dev:amd64. Preparing to unpack .../libffi-dev_3.2.1-4_amd64.deb ... Unpacking libffi-dev:amd64 (3.2.1-4) ... Selecting previously unselected package llvm-3.8-dev. Preparing to unpack .../llvm-3.8-dev_1%3a3.8-2ubuntu4_amd64.deb ...
Unpacking llvm-3.8-dev (1:3.8-2ubuntu4) ... Selecting previously unselected package manpages-dev. Preparing to unpack .../manpages-dev_4.04-2_all.deb ... Unpacking manpages-dev (4.04-2) ... Selecting previously unselected package pkg-config. Preparing to unpack .../pkg-config_0.29.1-0ubuntu1_amd64.deb ... Unpacking pkg-config (0.29.1-0ubuntu1) ... Selecting previously unselected package rename. Preparing to unpack .../archives/rename_0.20-4_all.deb ... Unpacking rename (0.20-4) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.1) ... Setting up libatm1:amd64 (1:2.5.1-1.5) ... Setting up libmnl0:amd64 (1.0.3-5) ... Setting up libpopt0:amd64 (1.16-10) ... Setting up libgdbm3:amd64 (1.8.3-13.1) ... Setting up libxau6:amd64 (1:1.0.8-1) ... Setting up libxdmcp6:amd64 (1:1.1.2-1.1) ... Setting up libxcb1:amd64 (1.11.1-1ubuntu1) ... Setting up libx11-data (2:1.6.3-1ubuntu2) ... Setting up libx11-6:amd64 (2:1.6.3-1ubuntu2) ... Setting up libxext6:amd64 (2:1.3.3-1) ... Setting up sgml-base (1.26+nmu4ubuntu1) ... Setting up perl-modules-5.22 (5.22.1-9ubuntu0.3) ... Setting up libperl5.22:amd64 (5.22.1-9ubuntu0.3) ... Setting up perl (5.22.1-9ubuntu0.3) ... update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode Setting up mime-support (3.59ubuntu1) ... Setting up libexpat1:amd64 (2.1.0-7ubuntu0.16.04.3) ... Setting up libffi6:amd64 (3.2.1-4) ... Setting up libsqlite3-0:amd64 (3.11.0-1ubuntu1) ... Setting up libssl1.0.0:amd64 (1.0.2g-1ubuntu4.12) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline Setting up libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) ... Setting up python2.7 (2.7.12-1ubuntu0~16.04.3) ... Setting up libpython-stdlib:amd64 (2.7.12-1~16.04) ...
Setting up python (2.7.12-1~16.04) ... Setting up libgmp10:amd64 (2:6.1.0+dfsg-2) ... Setting up libmpfr4:amd64 (3.1.4-1) ... Setting up libmpc3:amd64 (1.0.3-1) ... Setting up tzdata (2017c-0ubuntu0.16.04) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline Current default time zone: 'Etc/UTC' Local time is now: Sat May 5 04:27:22 UTC 2018. Universal Time is now: Sat May 5 04:27:22 UTC 2018. Run 'dpkg-reconfigure tzdata' if you wish to change it. Setting up bzip2 (1.0.6-8) ... Setting up libmagic1:amd64 (1:5.25-2ubuntu1) ... Setting up file (1:5.25-2ubuntu1) ... Setting up iproute2 (4.3.0-1ubuntu3.16.04.3) ... Setting up ifupdown (0.8.10ubuntu1.3) ... Creating /etc/network/interfaces. Setting up libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Setting up libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.10) ... Setting up isc-dhcp-client (4.3.3-5ubuntu12.10) ... Setting up isc-dhcp-common (4.3.3-5ubuntu12.10) ... Setting up less (481-2.1ubuntu0.2) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline Setting up libbsd0:amd64 (0.8.2-1) ... Setting up libnettle6:amd64 (3.2-1ubuntu0.16.04.1) ... Setting up libhogweed4:amd64 (3.2-1ubuntu0.16.04.1) ... Setting up libidn11:amd64 (1.32-3ubuntu1.2) ... Setting up libp11-kit0:amd64 (0.23.2-5~ubuntu16.04.1) ... Setting up libtasn1-6:amd64 (4.7-3ubuntu0.16.04.3) ... Setting up libgnutls30:amd64 (3.4.10-4ubuntu1.4) ... Setting up libxtables11:amd64 (1.6.0-2ubuntu3) ... Setting up netbase (5.3) ... Setting up openssl (1.0.2g-1ubuntu4.12) ... Setting up ca-certificates (20170717~16.04.1) ... debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline Setting up krb5-locales (1.13.2+dfsg-5ubuntu2) ... Setting up libroken18-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libasn1-8-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libkrb5support0:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libk5crypto3:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libkeyutils1:amd64 (1.5.9-8ubuntu1) ... Setting up libkrb5-3:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libgssapi-krb5-2:amd64 (1.13.2+dfsg-5ubuntu2) ... Setting up libhcrypto4-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libheimbase1-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libwind0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libhx509-5-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libkrb5-26-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libheimntlm0-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libgssapi3-heimdal:amd64 (1.7~git20150920+dfsg-4ubuntu1.16.04.1) ... Setting up libsasl2-modules-db:amd64 (2.1.26.dfsg1-14build1) ... Setting up libsasl2-2:amd64 (2.1.26.dfsg1-14build1) ... Setting up libldap-2.4-2:amd64 (2.4.42+dfsg-2ubuntu3.2) ... Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d-1ubuntu0.1) ... Setting up libcurl3-gnutls:amd64 (7.47.0-1ubuntu2.7) ... Setting up libedit2:amd64 (3.1-20150325-1ubuntu2) ... Setting up libglib2.0-0:amd64 (2.48.2-0ubuntu1) ... No schema files found: doing nothing. Setting up libglib2.0-data (2.48.2-0ubuntu1) ... Setting up libicu55:amd64 (55.1-7ubuntu0.4) ... Setting up libpipeline1:amd64 (1.4.1-2) ... Setting up libsasl2-modules:amd64 (2.1.26.dfsg1-14build1) ... Setting up libxml2:amd64 (2.9.3+dfsg1-1ubuntu0.5) ... Setting up libxmuu1:amd64 (2:1.1.2-2) ... Setting up manpages (4.04-2) ...
Setting up openssh-client (1:7.2p2-4ubuntu2.4) ... Setting up rsync (3.1.1-3ubuntu1.2) ... invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of restart. Setting up shared-mime-info (1.5-2ubuntu0.1) ... Setting up xauth (1:1.0.9-1ubuntu2) ... Setting up xdg-user-dirs (0.15-2ubuntu6.16.04.1) ... Setting up xml-core (0.13+nmu2) ... Setting up binfmt-support (2.1.6-1) ... mount: permission denied update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc. mount: permission denied update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc. invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of start. Setting up binutils (2.26.1-1ubuntu1~16.04.6) ... Setting up libc-dev-bin (2.23-0ubuntu10) ... Setting up linux-libc-dev:amd64 (4.4.0-122.146) ... Setting up libc6-dev:amd64 (2.23-0ubuntu10) ... Setting up libisl15:amd64 (0.16.1-1) ... Setting up cpp-5 (5.4.0-6ubuntu1~16.04.9) ... Setting up cpp (4:5.3.1-1ubuntu1) ... Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up gcc-5 (5.4.0-6ubuntu1~16.04.9) ... Setting up gcc (4:5.3.1-1ubuntu1) ... Setting up libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ...
Setting up g++-5 (5.4.0-6ubuntu1~16.04.9) ... Setting up g++ (4:5.3.1-1ubuntu1) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode Setting up make (4.1-6) ... Setting up libdpkg-perl (1.18.4ubuntu1.4) ... Setting up xz-utils (5.1.1alpha+20120614-2ubuntu2) ... update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode Setting up patch (2.7.5-1ubuntu0.16.04.1) ... Setting up dpkg-dev (1.18.4ubuntu1.4) ... Setting up build-essential (12.1ubuntu2) ... Setting up libllvm3.8:amd64 (1:3.8-2ubuntu4) ... Setting up libobjc4:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libobjc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.9) ... Setting up libclang1-3.8:amd64 (1:3.8-2ubuntu4) ... Setting up libclang-common-3.8-dev (1:3.8-2ubuntu4) ... Setting up clang-3.8 (1:3.8-2ubuntu4) ... Setting up curl (7.47.0-1ubuntu2.7) ... Setting up libfakeroot:amd64 (1.20.2-1ubuntu1) ... Setting up fakeroot (1.20.2-1ubuntu1) ... update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode Setting up liberror-perl (0.17-1.2) ... Setting up git-man (1:2.7.4-0ubuntu1.3) ... Setting up git (1:2.7.4-0ubuntu1.3) ... Setting up icu-devtools (55.1-7ubuntu0.4) ... Setting up libalgorithm-diff-perl (1.19.03-1) ... Setting up libalgorithm-diff-xs-perl (0.04-4build1) ... Setting up libalgorithm-merge-perl (0.08-3) ... Setting up libbsd-dev:amd64 (0.8.2-1) ... Setting up libcurl3:amd64 (7.47.0-1ubuntu2.7) ... Setting up libcurl4-openssl-dev:amd64 (7.47.0-1ubuntu2.7) ... Setting up libtinfo-dev:amd64 (6.0+20160213-1ubuntu1) ... Setting up libedit-dev:amd64 (3.1-20150325-1ubuntu2) ... Setting up libfile-fcntllock-perl (0.22-3) ... Setting up libicu-dev:amd64 (55.1-7ubuntu0.4) ... Setting up libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.3) ... Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
Setting up libssl-dev:amd64 (1.0.2g-1ubuntu4.12) ... Setting up libssl-doc (1.0.2g-1ubuntu4.12) ... Setting up llvm-3.8-runtime (1:3.8-2ubuntu4) ... mount: permission denied update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc. Setting up llvm-3.8 (1:3.8-2ubuntu4) ... Setting up libjsoncpp1:amd64 (1.7.2-1) ... Setting up libffi-dev:amd64 (3.2.1-4) ... Setting up llvm-3.8-dev (1:3.8-2ubuntu4) ... Setting up manpages-dev (4.04-2) ... Setting up pkg-config (0.29.1-0ubuntu1) ... Setting up rename (0.20-4) ... update-alternatives: using /usr/bin/file-rename to provide /usr/bin/rename (rename) in auto mode Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.1) ... Processing triggers for ca-certificates (20170717~16.04.1) ... Updating certificates in /etc/ssl/certs... 148 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Processing triggers for sgml-base (1.26+nmu4ubuntu1) ... Removing intermediate container 9413e8e47de6 ---> 9095c304757c Step 5/10 : ARG SWIFT_PLATFORM=ubuntu16.04 ---> Running in 520a54e6a6f3 Removing intermediate container 520a54e6a6f3 ---> 7510559c68e5 Step 6/10 : ARG SWIFT_BRANCH=swift-4.1-release ---> Running in 8b10901f7a42 Removing intermediate container 8b10901f7a42 ---> 98b501a2543e Step 7/10 : ARG SWIFT_VERSION=swift-4.1-RELEASE ---> Running in d43316b226e3 Removing intermediate container d43316b226e3 ---> 5b12a9e7e8ff Step 8/10 : ENV SWIFT_PLATFORM=$SWIFT_PLATFORM SWIFT_BRANCH=$SWIFT_BRANCH SWIFT_VERSION=$SWIFT_VERSION ---> Running in 9e2440fd6f0f Removing intermediate container 9e2440fd6f0f ---> 074b576c8827
Step 9/10 : RUN SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz && curl -fSsL $SWIFT_URL -o swift.tar.gz && curl -fSsL $SWIFT_URL.sig -o swift.tar.gz.sig && export GNUPGHOME="$(mktemp -d)" && tar -xzf swift.tar.gz --directory / --strip-components=1 && rm -r "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz && chmod -R o+r /usr/lib/swift ---> Running in 7eb559ffc45c Removing intermediate container 7eb559ffc45c ---> 28c481c0e9d6 Step 10/10 : RUN swift --version ---> Running in e3bf81d48e82 Swift version 4.1.1 (swift-4.1.1-RELEASE) Target: x86_64-unknown-linux-gnu Removing intermediate container e3bf81d48e82 ---> fe9cd801dc6b Successfully built fe9cd801dc6b Successfully tagged kishikawakatsumi/swift:4.1.1 ```
Avatar
Kishikawa Katsumi 05-May-18 04:29 AM
🙇🏻
👌 1
Avatar
hiragram 05-May-18 04:29 AM
びっくりしたw
Avatar
Kishikawa Katsumi 05-May-18 04:29 AM
申し訳ない。。。
作った私もびっくりしました。
Avatar
norio_nomura 05-May-18 04:31 AM
お、行単位行区切りで自動分割投稿する仕組みがあるのかな?>discord.js (edited)
Avatar
Kishikawa Katsumi 05-May-18 04:32 AM
discode.jsはsend(contents, options)みたいなAPIになっていて、options{split: true}で自動的に分割してくれます。
Avatar
norio_nomura 05-May-18 04:32 AM
なるほど。
Avatar
Kishikawa Katsumi 05-May-18 04:32 AM
ただ、いつも思ったよりたくさん出るので、今のところ使いどころがありません。。。
@swiftbot versions
🛠 1
Avatar
swiftbot BOT 05-May-18 04:37 AM
4.0.2 4.1.1 2018-04-25-a 2018-05-02-a 4.1 4.0.3 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 05-May-18 05:16 AM
GitHubのTags APIで2018-05-02-aが出てこないのなんでかな。 curl https://api.github.com/repos/apple/swift/tags
Avatar
norio_nomura 05-May-18 05:41 AM
GraphQLだと返ってきます。
{ "data": { "repository": { "refs": { "pageInfo": { "endCursor": "MTAw", "hasNextPage": true, "startCursor": "MQ==" }, "tags": [ { "name": "swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a" }, { "name": "swift-4.1.1-RELEASE" }, { "name": "swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a" }, …
Avatar
Kishikawa Katsumi 05-May-18 05:41 AM
@norio_nomura Thanks. GraphQL使ってみます。
REST APIはObsoleteになっていくのかなあ。
Avatar
norio_nomura 05-May-18 05:43 AM
ちなみにクエリはこんな感じ。
query ($owner: String!, $name: String!, $cursor: String = "") { repository(owner: $owner, name: $name) { refs(refPrefix: "refs/tags/", first: 100, after: $cursor, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) { pageInfo { endCursor hasNextPage startCursor } tags: nodes { name } } } }
Query Variables:
{ "owner": "apple", "name": "swift", "cursor": "" }
(edited)
ページングはcursorに前のendCursorを渡す。
curl https://api.github.com/repos/apple/swift/tagsでタグ一覧を取得する方法は、そもそもAPIドキュメントに載ってないので、非公式な動作なのかも? https://developer.github.com/v3/git/tags/
というか、ドキュメントに載ってなかったのでGraphQLを使うようにしました。
Avatar
Kishikawa Katsumi 05-May-18 05:49 AM
いや、ドキュメント見て作ったリクエストなのでどこかに載ってるはずです。
Releases APIからTags APIに行って、そこに載ってたと思います。
Avatar
norio_nomura 05-May-18 05:50 AM
なるほど、ありがとうございます。
Avatar
Kishikawa Katsumi 05-May-18 06:05 AM
@norio_nomura どうもどうも。いただいたクエリで取れました。
👍 1
Avatar
Kishikawa Katsumi 05-May-18 07:14 AM
@swiftbot !install --list
Avatar
swiftbot BOT 05-May-18 07:14 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a swift-DEVELOPMENT-SNAPSHOT-2018-04-21-a swift-DEVELOPMENT-SNAPSHOT-2018-04-20-a swift-DEVELOPMENT-SNAPSHOT-2018-04-19-a ...
Avatar
Kishikawa Katsumi 05-May-18 07:15 AM
@swiftbot versions
Avatar
swiftbot BOT 05-May-18 07:15 AM
2018-05-02-a 2018-04-25-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 05-May-18 07:16 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
swiftbot BOT 05-May-18 07:16 AM
install: missing destination file operand after 'swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a' Try 'install --help' for more information.
Avatar
Kishikawa Katsumi 05-May-18 07:17 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
swiftbot BOT 05-May-18 07:17 AM
install: missing destination file operand after 'swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a' Try 'install --help' for more information.
Avatar
Kishikawa Katsumi 05-May-18 07:22 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a
Avatar
swiftbot BOT 05-May-18 07:24 AM
Sending build context to Docker daemon 89.73MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 3cad3c7b2297 Removing intermediate container 3cad3c7b2297 ---> 14b761354421 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 1ac6435d7538 Removing intermediate container 1ac6435d7538 ---> e199f6c5ff72 Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in 0fb9c293500c Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [612 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [436 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3755 B] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] ...
64.19 KB
Avatar
Kishikawa Katsumi 05-May-18 07:25 AM
@swiftbot versions
Avatar
swiftbot BOT 05-May-18 07:25 AM
2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 05-May-18 10:00 AM
@swiftbot
import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription) import Foundation import RxSwift _ = Observable<String>.create { observerOfString in print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) return Disposables.create() } .subscribe { event in print(event) } import CryptoSwift let data = Data(bytes: [0x01, 0x02, 0x03]) let bytes = data.bytes print(bytes) print(Array<UInt8>(hex: "0x010203")) print(bytes.toHexString()) print("123".md5())
🛠 1
Avatar
swiftbot BOT 05-May-18 10:00 AM
Author icon kishikawakatsumi
import SwiftyMath import SwiftyTopology let S = SimplicialComplex.sphere(dim:3) let H = Homology(S, Int.self) print(H.detailDescription) import Foundation import RxSwift _ = Observable<String>.create { observerOfString in print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) return Disposables.create() } .subscribe { event in print(event) } import CryptoSwift let data = Data(bytes: [0x01, 0x02, 0x03]) let bytes = data.bytes print(bytes) print(Array<UInt8>(hex: "0x010203")) print(bytes.toHexString()) print("123".md5())
Version:
swift-4.1-RELEASE
Output:
H(S^3; 𝐙) = { 0 : 𝐙, [v₀], 1 : 0, [], 2 : 0, [], 3 : 𝐙, [(v₀, v₁, v₂, v₃) + -(v₀, v₁, v₂, v₄) + (v₀, v₁, v₃, v₄) + -(v₀, v₂, v₃, v₄) + (v₁, v₂, v₃, v₄)] } Observable created next(😉) completed [1, 2, 3] [1, 2, 3] 010203 202cb962ac59075b964b07152d234b70
Error:
Avatar
Kishikawa Katsumi 05-May-18 10:03 AM
^ SwiftyMathに加えてRxSwiftとCryptoSwiftを足してみました。 超簡単に追加できるようにしてあるので、追加したいものがあったらPRください。 https://github.com/kishikawakatsumi/swift-playground/blob/master/Libraries/All/Package.swift#L14-L22 ^ やり方は見たらわかります。
Contribute to swift-playground development by creating an account on GitHub.
Avatar
swift41 BOT 05-May-18 11:36 AM
4.1.1-RELEASE
Avatar
swiftTensorflow BOT 05-May-18 11:36 AM
DEVELOPMENT-2018-05-03-a
Avatar
Kishikawa Katsumi 06-May-18 01:13 AM
@swiftbot !install -l
Avatar
swiftbot BOT 06-May-18 01:13 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a swift-DEVELOPMENT-SNAPSHOT-2018-04-21-a swift-DEVELOPMENT-SNAPSHOT-2018-04-20-a swift-DEVELOPMENT-SNAPSHOT-2018-04-19-a ...
Avatar
Kishikawa Katsumi 06-May-18 01:14 AM
@norio_nomura DEVELOPMENT-2018-05-03-aっていうスナップショットはなんですか?
Avatar
norio_nomura 06-May-18 01:29 AM
swift-tensorflowです
Avatar
Kishikawa Katsumi 06-May-18 01:29 AM
あ、なるほど。確かに名前をよく見たらそうですね 😄
Avatar
cecil_ma 07-May-18 03:05 PM
@swiftbot print(pow(2,5))
Avatar
Kishikawa Katsumi 07-May-18 03:37 PM
@cecil_ma 実行するにはコードをコードブロック (バックティック3つ)で囲います。 (edited)
@swiftbot help
Avatar
swiftbot BOT 07-May-18 03:38 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 07-May-18 03:39 PM
@swiftbot
print(pow(2,5))
🛠 1
Avatar
swiftbot BOT 07-May-18 03:39 PM
Author icon kishikawakatsumi
print(pow(2,5))
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:1:7: error: use of unresolved identifier 'pow' print(pow(2,5)) ^~~
Avatar
Kishikawa Katsumi 07-May-18 03:44 PM
@swiftbot
import SwiftGlibc print(pow(2,5))
🛠 1
Avatar
swiftbot BOT 07-May-18 03:44 PM
Author icon kishikawakatsumi
import SwiftGlibc print(pow(2,5))
Version:
swift-4.1.1-RELEASE
Output:
32.0
Error:
Avatar
Kishikawa Katsumi 07-May-18 04:56 PM
@swiftbot —version 4.0.3
print("hello")
🛠 1
Avatar
swiftbot BOT 07-May-18 04:56 PM
Author icon kishikawakatsumi
print("hello")
Version:
swift-4.0.3-RELEASE
Output:
hello
Error:
Avatar
Kishikawa Katsumi 07-May-18 04:57 PM
^ そういえばSwiftはSmart Punctuationに対して特別なエラーメッセージを返してたなあと思って対応した。iPhoneから投稿しても平気になった。
👀 1
Avatar
tarunon 08-May-18 03:55 AM
なんかレスポンスかっこよくなってる
Avatar
Kishikawa Katsumi 08-May-18 04:15 AM
ちょっと試しでRichEmbedというのを使ってみました。1つのメッセージにできるので、編集等があった時の管理が簡単になりました。 ただEmbedは25個/メッセージですけど1Embedが1000文字までなので返せるOutputは半分になるところがデメリットですね。
Avatar
norio_nomura 09-May-18 02:02 AM
@swift-4.1.3
import Foundation var hint = addrinfo(), addrinfo0: UnsafeMutablePointer<addrinfo>? = nil #if _runtime(_ObjC) hint.ai_socktype = SOCK_STREAM #else hint.ai_socktype = Int32(SOCK_STREAM.rawValue) #endif let error = getaddrinfo("whois.nic.google", "nicname", &hint, &addrinfo0) guard error == 0 else { print(String.init(cString: gai_strerror(error))) exit(error) } defer { freeaddrinfo(addrinfo0) } var addrinfoNext = addrinfo0?.pointee while let addrinfo = addrinfoNext { defer { addrinfoNext = addrinfo.ai_next?.pointee } let sock = socket(addrinfo.ai_family, addrinfo.ai_socktype, addrinfo.ai_protocol) guard sock != -1, connect(sock, addrinfo.ai_addr, addrinfo.ai_addrlen) == 0 else { print(String(cString: strerror(errno))) continue } let handle = FileHandle(fileDescriptor: sock, closeOnDealloc: true) handle.write("xcode.app\r\n".data(using: .utf8)!) FileHandle.standardOutput.write(handle.readDataToEndOfFile()) }
(edited)
🛠 1
Avatar
swiftbot BOT 09-May-18 02:02 AM
(edited)
Author icon norio_nomura
import Foundation var hint = addrinfo(), addrinfo0: UnsafeMutablePointer<addrinfo>? = nil #if _runtime(_ObjC) hint.ai_socktype = SOCK_STREAM #else hint.ai_socktype = Int32(SOCK_STREAM.rawValue) #endif let error = getaddrinfo("whois.iana.org", "nicname", &hint, &addrinfo0) guard error == 0 else { print(String.init(cString: gai_strerror(error))) exit(error) } defer { freeaddrinfo(addrinfo0) } var addrinfoNext = addrinfo0?.pointee while let addrinfo = addrinfoNext { defer { addrinfoNext = addrinfo.ai_next?.pointee } let sock = socket(addrinfo.ai_family, addrinfo.ai_socktype, addrinfo.ai_protocol) guard sock != -1, connect(sock, addrinfo.ai_addr, addrinfo.ai_addrlen) == 0 else { print(String(cString: strerror(errno))) continue } let handle = FileHandle(fileDescriptor: sock, closeOnDealloc: true) handle.write("xcode.app\r\n".data(using: .utf8)!) FileHandle.standardOutput.write(handle.readDataToEndOfFile()) }
Version:
swift-4.1.1-RELEASE
Output:
Temporary failure in name resolution
Error:
Avatar
swift41 BOT 09-May-18 02:03 AM
% IANA WHOIS server % for more information on IANA, visit http://www.iana.org % This query returned 1 object refer: whois.nic.google domain: APP organisation: Charleston Road Registry Inc. address: 1600 Amphitheatre Parkway Mountain View, CA 94043 address: United States contact: administrative name: Domains Policy and Compliance organisation: Google Inc. address: 601 N. 34th Street address: Seattle, WA 98103 address: United States phone: 1 202 642 2325 fax-no: 1 650 492 5631 e-mail: iana-contact@google.com contact: technical name: Richard Roberto organisation: Google Inc address: 76 9th Avenue, 4th Floor address: New York, NY 10011 address: United States phone: 1 212 565 2633 fax-no: 1 650 492 5631 e-mail: crr-tech@google.com nserver: NS-TLD1.CHARLESTONROADREGISTRY.COM 2001:4860:4802:32:0:0:0:69 216.239.32.105 nserver: NS-TLD2.CHARLESTONROADREGISTRY.COM 2001:4860:4802:34:0:0:0:69 216.239.34.105 nserver: NS-TLD3.CHARLESTONROADREGISTRY.COM 2001:4860:4802:36:0:0:0:69 216.239.36.105 nserver: NS-TLD4.CHARLESTONROADREGISTRY.COM 2001:4860:4802:38:0:0:0:69 216.239.38.105 nserver: NS-TLD5.CHARLESTONROADREGISTRY.COM 2001:4860:4805:0:0:0:0:69 216.239.60.105 ds-rdata: 41971 8 2 858FEEE8930855598DB109C9705955EDF494FA641ED1CDD07A95C13357E9FD19 ds-rdata: 23684 8 2 3a5cc8a31e02c94aba6461912fabb7e9f5e34957bb6114a55a864d96aec31836 whois: whois.nic.google status: ACTIVE remarks: Registration information: http://www.registry.google created: 2015-06-25 changed: 2018-03-20 source: IANA Network is unreachable
Avatar
norio_nomura 09-May-18 02:05 AM
whois.iana.orgへの問い合わせは動くけど、whois.nic.googleへの問い合わせは動かないな。
Avatar
omochimetaru 09-May-18 02:05 AM
@swift-4.1.3
print(3)
Avatar
swift41 BOT 09-May-18 02:05 AM
3
Avatar
norio_nomura 09-May-18 02:05 AM
手元のREPLだとうまくいくのに>whois.nic.google
Avatar
omochimetaru 09-May-18 02:05 AM
@swift-4.1.3
print(3)
Avatar
swift41 BOT 09-May-18 02:05 AM
3
Avatar
omochimetaru 09-May-18 02:06 AM
さっきのnorioさんの書き込みに両方のbotが反応したのはなぜだ
Avatar
norio_nomura 09-May-18 02:06 AM
先に岸川さんのボットへ問い合わせて、その後、僕のボットへのメンションへ投稿を書き換えました。
Avatar
omochimetaru 09-May-18 02:06 AM
あ、なるほど。
Avatar
norio_nomura 09-May-18 02:07 AM
岸川さんのボットはネットワークアクセス遮断されてるのを忘れていたので。
試行錯誤がしやすい様に、ボットも投稿の編集/削除に追従する様になっています。
ボットにこれを出力させたかった。
Domain Name: xcode.app Registry Domain ID: 2C5582619-APP Registrar WHOIS Server: whois.nic.google Registrar URL: http://www.ascio.com Updated Date: 2018-04-05T15:45:23Z Creation Date: 2018-03-30T11:42:39Z Registry Expiry Date: 2019-03-30T11:42:39Z Registrar: Ascio Technologies, Inc. Registrar IANA ID: 106 Registrar Abuse Contact Email: abuse@ascio.com Registrar Abuse Contact Phone: +44.2070159370 Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Registrant Organization: Apple Inc. Registrant State/Province: CA Registrant Country: US Name Server: a.ns.apple.com Name Server: b.ns.apple.com Name Server: c.ns.apple.com Name Server: d.ns.apple.com DNSSEC: unsigned
Avatar
swift42 BOT 09-May-18 02:57 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a
Avatar
Kishikawa Katsumi 09-May-18 02:58 AM
@swiftbot !install swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a
Avatar
swiftbot BOT 09-May-18 03:01 AM
Sending build context to Docker daemon 89.89MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 74672f4fa8d7 Removing intermediate container 74672f4fa8d7 ---> 59ef556a8cc5 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 5be2396d3584 Removing intermediate container 5be2396d3584 ---> cb7e4d4d82b3 Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in a914c461bbe6 Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [625 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [438 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3759 B] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] ...
64.19 KB
Avatar
norio_nomura 09-May-18 03:48 AM
swift-4.2-branchmasterでそれぞれスナップショットが出てますよ。 (edited)
Avatar
Kishikawa Katsumi 09-May-18 04:22 AM
ども。のむらさんは全部自動化されてます?
@swiftbot !install -l
Avatar
swiftbot BOT 09-May-18 04:24 AM
swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-23-a swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a swift-DEVELOPMENT-SNAPSHOT-2018-04-21-a ...
Avatar
Kishikawa Katsumi 09-May-18 04:26 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a
Avatar
swiftbot BOT 09-May-18 04:28 AM
Sending build context to Docker daemon 89.89MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in 6131c07eaec0 Removing intermediate container 6131c07eaec0 ---> 3be293815ff5 Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in f6ad39fa35f5 Removing intermediate container f6ad39fa35f5 ---> cfb1b891f8e9 Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in d1d8b173ba38 Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:7 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] Get:8 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [255 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1002 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB] ...
64.19 KB
Avatar
norio_nomura 09-May-18 07:49 AM
まだ自動化できていません。
CircleCIのcronで自動化しようとして、まだ途中。
Avatar
Kishikawa Katsumi 09-May-18 07:57 AM
CIのスケジューリングでやるというのは良いアイデアですね。マネします。
Avatar
omochimetaru 09-May-18 08:15 AM
Discordから命令するとパッケージ入るのか
Avatar
Kishikawa Katsumi 09-May-18 08:28 AM
私がメンションした場合に限り、ターミナルの操作とかができるようになっています。
@swiftbot echo "hello"
ダメだった。なんかバグがあるな。。。
Avatar
omochimetaru 09-May-18 10:45 AM
おもしろいです
Avatar
Kishikawa Katsumi 09-May-18 11:40 AM
@swiftbot !echo "hello"
Avatar
swiftbot BOT 09-May-18 11:40 AM
hello
Avatar
Kishikawa Katsumi 09-May-18 11:40 AM
^ ちゃんと動いてた。自分で作ったのに仕様を勘違いしていた。
Avatar
omochimetaru 09-May-18 11:41 AM
@swiftbot !echo “hello”
ちゃんと無視された
Avatar
Kishikawa Katsumi 09-May-18 11:45 AM
大丈夫だと思います。仮に操作できても大事には至らないはず。
Avatar
norio_nomura 10-May-18 03:14 PM
-以降のオプションをCommandLine.argumentsで取れる様になりました。 @swift-4.1.3 -Onone - -arg1 value1
print(CommandLine.arguments)
Avatar
swift41 BOT 10-May-18 03:14 PM
["-", "-arg1", "value1"]
Avatar
norio_nomura 10-May-18 03:15 PM
ボットとして使い道があるかどうか分かりませんが…
Avatar
norio_nomura 11-May-18 07:50 AM
dockerイメージの自動更新をCircleCIのcronで実行する様にしました。 https://circleci.com/gh/norio-nomura/docker-swift
Hosted Continuous Integration for web applications. Set up your application for testing in one click, on the fastest testing platform on the internet.
CircleCIでgithub.com/apple/swiftのタグを取得 -> 既存のものより新しいものがあったら Dockerfile を生成してdockerビルドテスト -> ビルドOKなら新しいDockerfileをgithubへプッシュ -> Docker Hubで自動ビルドして公開
あとは、Docker Hubで新しいswiftのdockerイメージが公開されたら、それを元にボットを自動更新したい…
Avatar
norio_nomura 12-May-18 01:20 AM
@swift-4.1.3 @swift-4.2.4 @swift-nightly
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
(edited)
Avatar
swift42 BOT 12-May-18 01:20 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-10-a
Avatar
swiftTensorflow BOT 12-May-18 01:20 AM
DEVELOPMENT-2018-05-10-a
Avatar
Kishikawa Katsumi 12-May-18 02:23 AM
@swiftbot $install -l
Avatar
swiftbot BOT 12-May-18 02:23 AM
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a swift-DEVELOPMENT-SNAPSHOT-2018-05-11-a swift-DEVELOPMENT-SNAPSHOT-2018-05-10-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-10-a swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a swift-4.1.1-RELEASE swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a swift-DEVELOPMENT-SNAPSHOT-2018-04-24-a ...
Avatar
lovee 15-May-18 03:22 AM
@swift-4.1.3
import Foundation protocol Operand: Numeric {} typealias Operator<Value: Operand> = (Value, Value) -> Value indirect enum Node<Value: Operand> { case v(Value) case op(Node<Value>, Operator<Value>, Node<Value>) func evaluate() -> Value { switch self { case .v(let value): return value case .op(let operand1, let `operator`, let operand2): return `operator`(operand1.evaluate(), operand2.evaluate()) } } } extension Int: Operand {} extension Node: ExpressibleByIntegerLiteral where Value == Int { typealias IntegerLiteralType = Int init(integerLiteral value: Value) { self = .v(value) } } let root: Node<Int> = .op(1, +, .op(2, *, 3)) print(root.evaluate())
(edited)
Avatar
swift41 BOT 15-May-18 03:22 AM
7
(edited)
Avatar
t.ae 16-May-18 02:59 AM
@swiftbot
import Foundation print(TimeZone(abbreviation: "JST"))
🛠 1
Avatar
swiftbot BOT 16-May-18 02:59 AM
Author icon t.ae
import Foundation print(TimeZone(abbreviation: "JST"))
Version:
swift-4.1.1-RELEASE
Output:
Optional(Asia/Tokyo (fixed))
Error:
/usercode/main.swift:2:7: warning: expression implicitly coerced from 'TimeZone?' to Any print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usercode/main.swift:2:7: note: provide a default value to avoid this warning print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> /usercode/main.swift:2:7: note: force-unwrap the value to avoid this warning print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! /usercode/main.swift:2:7: note: explicitly cast to Any with 'as Any' to silence this warning print(TimeZone(abbreviation: "JST")) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ as Any
Avatar
t.ae 16-May-18 03:39 AM
@swiftbot
import Foundation import CoreFoundation print(CFTimeZoneCopyAbbreviationDictionary())
🛠 1
Avatar
swiftbot BOT 16-May-18 03:39 AM
Author icon t.ae
import Foundation import CoreFoundation print(CFTimeZoneCopyAbbreviationDictionary())
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: customMirror is not yet implemented: file Foundation/NSDictionary.swift, line 691 /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fa9e279b390] /usr/lib/swift/linux/libswiftCore.so(+0x2baf79)[0x7fa9dd9d9f79] /usr/lib/swift/linux/libswiftCore.so(_T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstF+0x2c)[0x7fa9dd86c46c] /usr/lib/swift/linux/libFoundation.so(+0x50438f)[0x7fa9dc5b238f] /usr/lib/swift/linux/libFoundation.so(+0x50425a)[0x7fa9dc5b225a] /usr/lib/swift/linux/libFoundation.so(+0x41451b)[0x7fa9dc4c251b] /usr/lib/swift/linux/libswiftCore.so(+0x2f3af8)[0x7fa9dda12af8] /usr/lib/swift/linux/libswiftCore.so(+0x2f5221)[0x7fa9dda14221] /usr/lib/swift/linux/libswiftCore.so(+0x34d751)[0x7fa9dda6c751] /usr/lib/swift/linux/libswiftCore.so(+0x34e72e)[0x7fa9dda6d72e] /usr/lib/swift/linux/libswiftCore.so(+0x21ee99)[0x7fa9dd93de99] ...
Avatar
t.ae 16-May-18 03:56 AM
@swiftbot
import Foundation let date = Date() let timeZone = TimeZone(secondsFromGMT: 0)! let cal = Calendar(identifier: .gregorian) let comp = cal.dateComponents(in: timeZone, from: date) print(comp.second) print(comp.nanosecond)
🛠 1
Avatar
swiftbot BOT 16-May-18 03:56 AM
Author icon t.ae
import Foundation let date = Date() let timeZone = TimeZone(secondsFromGMT: 0)! let cal = Calendar(identifier: .gregorian) let comp = cal.dateComponents(in: timeZone, from: date) print(comp.second) print(comp.nanosecond)
Version:
swift-4.1.1-RELEASE
Output:
Optional(14) nil
Error:
/usercode/main.swift:7:7: warning: expression implicitly coerced from 'Int?' to Any print(comp.second) ^~~~~~~~~~~ /usercode/main.swift:7:12: note: provide a default value to avoid this warning print(comp.second) ~~~~~^~~~~~ ?? <#default value#> /usercode/main.swift:7:12: note: force-unwrap the value to avoid this warning print(comp.second) ~~~~~^~~~~~ ! /usercode/main.swift:7:12: note: explicitly cast to Any with 'as Any' to silence this warning print(comp.second) ~~~~~^~~~~~ as Any /usercode/main.swift:8:7: warning: expression implicitly coerced from 'Int?' to Any print(comp.nanosecond) ^~~~~~~~~~~~~~~ /usercode/main.swift:8:12: note: provide a default value to avoid this warning print(comp.nanosecond) ~~~~~^~~~~~~~~~ ?? <#default value#> /usercode/main.swift:8:12: note: force-unwrap the value to avoid this warning print(comp.nanosecond) ~~~~~^~~~~~~~~~ ...
Avatar
Biacco42 16-May-18 10:21 AM
@swiftbot
import Foundation import RxSwift class Hoge: NSObject {} extension Reactive where Base == Hoge { class Piyo {} var hoge: Observable<Int> { return Observable.create { observer in var piyo = Piyo() observer.onNext(42) return Disposables.create {} } } } let hoge = Hoge() hoge.rx.hoge.subscribe(onNext: { res in print(res) })
(edited)
🛠 1
Avatar
swiftbot BOT 16-May-18 10:21 AM
(edited)
Author icon Biacco42
import Foundation import RxSwift class Hoge: NSObject {} extension Reactive where Base == Hoge { class Piyo {} var hoge: Observable<Int> { return Observable.create { observer in var piyo = Piyo() observer.onNext(42) return Disposables.create {} } } } let hoge = Hoge() hoge.rx.hoge.subscribe(onNext: { res in print(res) })
Version:
swift-4.1.1-RELEASE
Output:
42
Error:
/usercode/main.swift:10:17: warning: initialization of variable 'piyo' was never used; consider replacing with assignment to '_' or removing it var piyo = Piyo() ~~~~^~~~ _ /usercode/main.swift:19:14: warning: result of call to 'subscribe(onNext:onError:onCompleted:onDisposed:)' is unused hoge.rx.hoge.subscribe(onNext: { res in ^ ~~~~~~~~~~~~~~~~~
Avatar
omochimetaru 16-May-18 10:26 AM
@swiftbot --help
@swiftbot help
Avatar
swiftbot BOT 16-May-18 10:26 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
omochimetaru 16-May-18 10:26 AM
@swiftbot contribute
Avatar
swiftbot BOT 16-May-18 10:26 AM
Contributions Welcome!
All contributions (no matter if small) are always welcome.
Avatar
omochimetaru 16-May-18 10:29 AM
@swiftbot
import RxSwift
🛠 1
Avatar
swiftbot BOT 16-May-18 10:29 AM
Author icon omochimetaru
import RxSwift
Version:
swift-4.1.1-RELEASE
Output:
Error:
Avatar
omochimetaru 16-May-18 10:30 AM
@swiftbot versions
Avatar
swiftbot BOT 16-May-18 10:30 AM
2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
omochimetaru 16-May-18 10:31 AM
@swiftbot --version=4.1,4.0.3,3.1.1,3.0.2
import RxSwift
🛠 1
Avatar
swiftbot BOT 16-May-18 10:31 AM
Author icon omochimetaru
import RxSwift
Version:
swift-4.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Version:
swift-4.0.3-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Version:
swift-3.1.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Version:
swift-3.0.2-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'RxSwift' import RxSwift ^
Avatar
Biacco42 16-May-18 10:39 AM
バージョン違いで壊れるのデモしたかったけどできなかた
Avatar
Kishikawa Katsumi 16-May-18 11:20 AM
外部フレームワークは特定のバージョンにしか入れてないんですよね。予定はあってやり方も頭の中にはあるんですけど。
特に過去のバージョンにリンクさせるにはまずSwift 3.xで動くバージョンはどれなのかというところをやらないといけないのでそれが面倒に思っています。Snapshotで動かすのは最新のリリースかmasterでいいと思うんですけど。
Avatar
Kishikawa Katsumi 16-May-18 11:31 AM
今考えてるのは https://github.com/kishikawakatsumi/swift-playground/tree/master/Libraries/All ^ ここを4.1.1/Libraries/*3.0.2/Libraries/* ... のようにディレクトリでバージョニングして、それぞれのPackage.swiftでそのバージョンで使うライブラリを指定するって感じに改修ですね。 そうすると使う方(Botのプログラム)で -L ${SWIFT_VERSION}/Libraries/All のように切り替えられるのでうまくいくと思うんでなんだったらPRしてくれると 😄 です (edited)
Contribute to swift-playground development by creating an account on GitHub.
👀 1
Avatar
swift42 BOT 16-May-18 12:46 PM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a
Avatar
noppe 17-May-18 02:43 AM
@swiftbot --version=4.1,4.0,3.1.1
import Foundation protocol EnumCollection: Hashable { static var all: [Self] { get } } extension EnumCollection { static func cases() -> AnySequence<Self> { typealias SelfType = Self return AnySequence { () -> AnyIterator<SelfType> in var raw = 0 return AnyIterator { let current: Self = withUnsafePointer(to: &raw) { $0.withMemoryRebound(to: SelfType.self, capacity: 1) { $0.pointee } } guard current.hashValue == raw else { return nil } raw += 1 return current } } } static var all: [Self] { return Array(self.cases()) } } enum SampleEnum: String, EnumCollection { case hoge = "hoge" case foo case bar = "BAR" } print(SampleEnum.all)
(edited)
🛠 1
Avatar
swiftbot BOT 17-May-18 02:44 AM
(edited)
Author icon noppe
import Foundation protocol EnumCollection: Hashable { static var all: [Self] { get } } extension EnumCollection { static func cases() -> AnySequence<Self> { typealias SelfType = Self return AnySequence { () -> AnyIterator<SelfType> in var raw = 0 return AnyIterator { let current: Self = withUnsafePointer(to: &raw) { $0.withMemoryRebound(to: SelfType.self, capacity: 1) { $0.pointee } } guard current.hashValue == raw else { return nil } raw += 1 return current } } } static var all: [Self] { return Array(self.cases()) } } enum SampleEnum: String, EnumCollection { case hoge = "hoge" case foo case bar = "BAR" } print(SampleEnum.all)
Version:
swift-4.1-RELEASE
Output:
[main.SampleEnum.hoge, main.SampleEnum.foo, main.SampleEnum.bar]
Error:
Version:
swift-4.0-RELEASE
Output:
[main.SampleEnum.hoge, main.SampleEnum.foo, main.SampleEnum.bar]
Error:
Version:
swift-3.1.1-RELEASE
Output:
[main.SampleEnum.hoge, main.SampleEnum.foo, main.SampleEnum.bar]
Error:
Avatar
swiftNightly BOT 18-May-18 01:32 AM
DEVELOPMENT-SNAPSHOT-2018-05-17-a
Avatar
swift41 BOT 18-May-18 01:32 AM
4.1-DEVELOPMENT-SNAPSHOT-2018-05-17-a
Avatar
swift42 BOT 18-May-18 01:32 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a
Avatar
norio_nomura 18-May-18 01:35 AM
スナップショットのDockerイメージ作成からDiscordボットの更新まで自動化出来た。
tensorflowを除いて。
Avatar
omochimetaru 18-May-18 01:48 AM
@swift-nightly -v (edited)
Avatar
swiftNightly BOT 18-May-18 01:48 AM
stderr:
Swift version 4.2-dev (LLVM c30b3a99bf, Clang 1bc45fa980, Swift e96fcee6cd) Target: x86_64-unknown-linux-gnu /usr/bin/lldb --repl=-disable-objc-interop error: failed to launch REPL process: process launch failed: 'A' packet returned an error: 8
(edited)
Avatar
norio_nomura 18-May-18 01:53 AM
@swift-nightly @swift-4.2.4 -version (edited)
Avatar
swiftNightly BOT 18-May-18 01:53 AM
Swift version 4.2-dev (LLVM c30b3a99bf, Clang 1bc45fa980, Swift e96fcee6cd) Target: x86_64-unknown-linux-gnu
(edited)
Avatar
swift42 BOT 18-May-18 01:53 AM
Swift version 4.2-dev (LLVM ae60dc0632, Clang 91ee593a0d, Swift f58f5286fd) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 18-May-18 01:54 AM
nightlyはmasterブランチから来てます。
今のswift41はスナップショットになってます。
@swift-4.1.3 --version
Avatar
swift41 BOT 18-May-18 01:56 AM
Swift version 4.1.2-dev (LLVM 1a7347a5f0, Clang cd84be6c42, Swift 0b46ecacfe) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 18-May-18 03:14 AM
@swift-tensorflow format --help
Avatar
swiftTensorflow BOT 18-May-18 03:14 AM
exit status: 1 with stdout:
OVERVIEW: Swift Format Tool USAGE: swift [options] <inputs> DEBUG/DEVELOPMENT OPTIONS: -driver-always-rebuild-dependents Always rebuild dependents of files that have been modified -driver-batch-seed <value> Use the given seed value to randomize batch-mode partitions -driver-print-actions Dump list of actions to perform -driver-print-bindings Dump list of job inputs and outputs -driver-print-derived-output-file-map Dump the contents of the derived output file map -driver-print-jobs Dump list of jobs to execute -driver-print-output-file-map Dump the contents of the output file map -driver-show-incremental With -v, dump information about why files are being rebuilt -driver-show-job-lifecycle Show every step in the lifecycle of driver jobs -driver-skip-execution Skip execution of subtasks when performing compilation -driver-use-filelists Pass input files as filelists whenever possible -driver-use-frontend-path <value> Use the given executable to perform compilations MODES: -dump-ast Parse and type-check input file(s) and dump AST(s) -dump-interface-hash Parse input file(s) and dump interface token hash(es) -dump-parse Parse input file(s) and dump AST(s) -dump-scope-maps <expanded-or-list-of-line:column> Parse and type-check input file(s) and dump the scope map(s) -dump-type-refinement-contexts Type-check input file(s) and dump type refinement contexts(s) -emit-assembly Emit assembly file(s) (-S) -emit-bc Emit LLVM BC file(s) -emit-executable Emit a linked executable -emit-imported-modules Emit a list of the imported modules -emit-ir Emit LLVM IR file(s) -emit-library Emit a linked libra
Avatar
norio_nomura 18-May-18 03:15 AM
swift-tensorflowにはgoogleのswift-formatが入ってるぽい? (edited)
@swift-nightly format --help
Avatar
swiftNightly BOT 18-May-18 03:15 AM
OVERVIEW: Swift Format Tool USAGE: swift [options] <inputs> OPTIONS: -help Display available options -in-place Overwrite input file with formatted file. -indent-switch-case Indent cases in switch statements. -indent-width <n> Number of characters to indent. -line-range <n:n> <start line>:<end line>. Formats a range of lines (1-based). Can only be used with one input file. -o <file> Write output to <file> -tab-width <n> Width of tab character. -use-tabs Use tabs for indentation.
Avatar
koher 18-May-18 03:43 AM
@swift-4.2.4
for _ in 0..<10 { print(Int.random(in: 0..<10)) }
Avatar
swift42 BOT 18-May-18 03:43 AM
6 9 3 1 5 3 2 9 4 5
Avatar
norio_nomura 20-May-18 09:57 AM
Vapor3をインポートできる様になりました。 @swift-4.1.3
import Vapor let app = try Application() let client = try app.make(Client.self) let response = try client.get("http://www.apple.com/").wait() print(response.http.status)
Avatar
swift41 BOT 20-May-18 09:57 AM
ok
Avatar
norio_nomura 20-May-18 10:06 AM
Vapor3が依存するSwiftNIOも。 @swift-4.1.3
import NIO struct E: Error {} let eventLoop = EmbeddedEventLoop() let promises: [EventLoopPromise<Void>] = (0..<100).map { (_: Int) in eventLoop.newPromise() } let futures = promises.map { $0.futureResult } let fN: EventLoopFuture<Void> = EventLoopFuture<Void>.andAll(futures, eventLoop: eventLoop) _ = promises.map { $0.fail(error: E()) } do { () = try fN.wait() print("should've thrown an error") } catch _ as E { print("good") } catch let e { print("error of wrong type \(e)") }
Avatar
swift41 BOT 20-May-18 10:06 AM
good
Avatar
norio_nomura 20-May-18 10:31 AM
Cのソースを含むパッケージをビルドしておいてインポートする場合、SwiftPM(llbuild)がモジュールをビルドする際にswiftcへ渡すオプションを.build/debug.yamlから取り出して、それを渡すと良い。 https://github.com/norio-nomura/SwiftCompilerDiscordappBot/blob/8962b0dec3723876b2ac8a105653fce8567025eb/Sources/SwiftCompilerDiscordappBot/App.swift#L201-L207 (edited)
SwiftCompilerDiscordappBot - Swift Compiler Discordapp Bot
Avatar
kateinoigakukun 21-May-18 10:04 AM
@swiftbot --version=4.0,3.1.1
class A { init(a: A) { } } class B: A { init() { super.init(a: self) } }
Avatar
omochimetaru 21-May-18 10:05 AM
おや?
Avatar
kateinoigakukun 21-May-18 10:06 AM
ステータスがグレーだ
Avatar
omochimetaru 21-May-18 10:08 AM
@swift-nightly @swift-4.0.3
class A { init(a: A) { } } class B: A { init() { super.init(a: self) } }
Avatar
swift40 BOT 21-May-18 10:08 AM
exit status: 1 with stderr:
<stdin>:8:23: error: 'self' used before super.init call super.init(a: self) ^
Avatar
swiftNightly BOT 21-May-18 10:08 AM
stderr:
<stdin>:8:15: error: 'self' used before 'super.init' call super.init(a: self) ^
Avatar
omochimetaru 21-May-18 10:08 AM
3系だと渡せるん?
Avatar
kateinoigakukun 21-May-18 10:08 AM
swift3だと通りますこれ
webは生きてた
Avatar
omochimetaru 21-May-18 10:11 AM
どっかで話題を見たような気もする Bにstored propery作ってB.initの中で渡されたAのそれを触ると死にそう
あいや、ちがうな、それは変だ
class A { init(a: B) {} } class B: A { var s: String init() { self.s = "aaa" super.init(a: self) } }
0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -module-name main 1. While running pass #34 SILFunctionTransform "Definite Initialization" on SILFunction "@_TFC4main1BcfT_S0_". Aborted (core dumped)
Avatar
kateinoigakukun 21-May-18 10:26 AM
class A { let hoge: C init(a: B) { a.foo() self.hoge = .init() } } class C {} class B: A { init() { super.init(a: self) } func foo() { print(self.hoge) } } B.init().foo()
壊した!
Avatar
Kishikawa Katsumi 21-May-18 02:36 PM
@swiftbot
Botだけ落ちてる?死活監視はWebしか入れてないから気づかなかったのか。
@swiftbot
Avatar
swiftbot BOT 21-May-18 02:38 PM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 21-May-18 02:39 PM
DigitalOceanのメンテナンスは関係あるかな。Webと一緒のホストだからWebだけ生きてるということはこちら側の問題だと思うけど。
Avatar
norio_nomura 22-May-18 02:11 AM
そういえば少し前に、僕のbotもいくつか勝手にオフラインになってたかも。手動で再起動した気がする。
Avatar
Kishikawa Katsumi 22-May-18 02:53 AM
Botの死活監視は良い方法ありますかね。
Swiftイメージのアップデートを自動化したらそれでわかるか。
Avatar
norio_nomura 22-May-18 03:12 AM
ボット関連の通知(DockerHubへのpush, Herokuのbuild)は、webhook経由で管理用Discordチャンネルへ投稿して、それをiOSのプッシュ通知で受け取ってる。
ボットがオフラインになったかどうか?の監視は、ボットを監視するボットを作って、それにメールを送らせるとかさせれば良いのかな。
Need a Bot to monitor the status of your server Bots and notify you if any Bots go offline? Try WatchBot... I mean Watchman (Bot)
Avatar
Kishikawa Katsumi 22-May-18 03:17 AM
あるんだ。これを入れたら我々のbotを全部監視してもらえるかな?
Avatar
norio_nomura 22-May-18 03:22 AM
それのソースコードを探したけど、見つけられないな… https://github.com/Anu6is?tab=repositories (edited)
Anu6is has 17 repositories available. Follow their code on GitHub.
Avatar
Kishikawa Katsumi 22-May-18 03:29 AM
私のBotとのむらさんのBotで監視しあうという手もあるかな。DMで反応を確認するとかでいいんじゃないか。
Avatar
norio_nomura 22-May-18 03:30 AM
そうね。
Avatar
Kishikawa Katsumi 22-May-18 03:30 AM
ではそういう内容のPRを近々送るかも(送らないかも)
Avatar
omochimetaru 22-May-18 03:31 AM
面白いw
Avatar
norio_nomura 22-May-18 03:35 AM
このイベントをチェックすれば良いのかな。 https://discordapp.com/developers/docs/topics/gateway#presence-update
Integrate your service with Discord - whether it's a bot or a game or your whatever you wildest imagination can come up with.
特定のユーザーが特定の時間オフラインだったら通知する。
作るか。
Avatar
norio_nomura 22-May-18 03:46 AM
通知はメールじゃなくてwebhooksがいいかな?
Avatar
Kishikawa Katsumi 22-May-18 03:46 AM
Webhookを使えば再起動を自動化できるかな。
Avatar
norio_nomura 22-May-18 03:53 AM
む、とりあえず、ボット自身がオフライン継続してることを検知したら、iftttの https://ifttt.com/maker_webhooks を呼ぶ様にしようかと。 (edited)
Connect Webhooks to IFTTT, Email, maker_webhooks and more.
あいや、通知目的ならDiscordチャンネルへの投稿webhooksを呼んだ方が良いかも。
再起動自動化はどうなんだろう? 🤔
通知はやっぱり別サービスであるiftttのwebhooksにするか。 (edited)
iftttのアプレット使えば、herokuの再起動とかも出来そう。
Avatar
koher 24-May-18 07:44 AM
@swift-4.2.4
var a = Random.default var b = a print(a.next()) print(b.next())
Avatar
swift42 BOT 24-May-18 07:44 AM
2190522142258413190 6214093798825593358
👍 1
Avatar
koher 24-May-18 07:48 AM
@swift-4.2.4
struct LinearCongruentialGenerator : RandomNumberGenerator { private var seed: UInt64 init(seed: UInt64 = 0) { self.seed = seed } mutating func next() -> UInt64 { seed = 6364136223846793005 &* seed &+ 1442695040888963407 return seed } } var a = LinearCongruentialGenerator() var b = a print(a.next()) print(b.next())
Avatar
swift42 BOT 24-May-18 07:48 AM
1442695040888963407 1442695040888963407
Avatar
kateinoigakukun 24-May-18 09:31 AM
@swiftbot --version=4.0.3
struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension B: C {}
🛠 1
Avatar
swiftbot BOT 24-May-18 09:31 AM
Author icon kateinoigakukun
struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension B: C {}
Version:
swift-4.0.3-RELEASE
Output:
Error:
Avatar
kateinoigakukun 24-May-18 09:32 AM
これ、Swift4.1以前からCond confが使えてませんか??
@swiftbot --version=4.0.3
struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension A: C where T1 == Int {}
🛠 1
Avatar
swiftbot BOT 24-May-18 09:32 AM
Author icon kateinoigakukun
struct A<T1, T2> {} typealias B<T> = A<Int, T> typealias D = A<Int, Int> protocol C {} extension A: C where T1 == Int {}
Version:
swift-4.0.3-RELEASE
Output:
Error:
/usercode/main.swift:7:1: error: extension of type 'A' with constraints cannot have an inheritance clause extension A: C where T1 == Int {} ^ ~
Avatar
kateinoigakukun 24-May-18 09:33 AM
これが通らないのに上が通るのおかしい気がする
Avatar
tarunon 24-May-18 09:33 AM
typealiasのextensionは壊れてるのがしばしば話題に上がってた気がする
condconfが出来るように一見見えるが、その実conditionalじゃないやつも拡張されてるし、なんなら壊れてる、みたいな感じです (edited)
Avatar
kateinoigakukun 24-May-18 09:36 AM
ヤバですね
cond confが無い世界で書いてたはずなのに、extension Single: HogeProtocol {} が書けてしまったので。。。
Avatar
tarunon 24-May-18 09:39 AM
ぶっ壊れてそう
Avatar
norio_nomura 24-May-18 12:02 PM
swift-tensorflow以外はVaporを使える様になりました。 @swift-4.1.3 @swift-4.2.4 @swift-nightly
import Vapor let app = try Application() let client = try app.make(Client.self) let response = try client.get("http://www.apple.com/").wait() print(response.http.status)
Avatar
swift41 BOT 24-May-18 12:02 PM
ok
Avatar
swift42 BOT 24-May-18 12:02 PM
ok
Avatar
swiftNightly BOT 24-May-18 12:02 PM
ok
Avatar
omochimetaru 30-May-18 05:53 AM
@swiftbot --versions
Avatar
Kishikawa Katsumi 30-May-18 05:53 AM
むむ
Avatar
omochimetaru 30-May-18 05:54 AM
ボットさん、おねむ
Avatar
Kishikawa Katsumi 30-May-18 05:57 AM
Webは死活監視を入れてて、間違いなくずっと生きていて、Botは少なくともこの何日かは使われてなかったわけなので(DMで使われてたらわからないけど) クラッシュしてるとかじゃないと思うんですよね。 しばらく使ってなかったらInactiveになるとか何か見逃している設定があるのだろうか。
@swiftbot
Avatar
swiftbot BOT 30-May-18 05:58 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
Kishikawa Katsumi 30-May-18 05:58 AM
何もしてないけど起きた。
@swiftbot $install -l
Avatar
swiftbot BOT 30-May-18 05:58 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-29-a swift-DEVELOPMENT-SNAPSHOT-2018-05-29-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-28-a swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-28-a swift-DEVELOPMENT-SNAPSHOT-2018-05-28-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-27-a swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-27-a swift-DEVELOPMENT-SNAPSHOT-2018-05-27-a swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-26-a ...
Avatar
Kishikawa Katsumi 30-May-18 05:59 AM
2018-05-29のスナップショットはまだ入ってないので入れます。とりあえずswift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-aでいいんですかね?
実はDEVELOPMENT-SNAPSHOT-2018-05-29-aしか見てないので、同じ日付のうち、どれか1つしか入りません。
Avatar
omochimetaru 30-May-18 06:01 AM
ふむふむ
そうですね、 BundleID が org.swift.4220180529a なのでswift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-aであってそうです
Avatar
Kishikawa Katsumi 30-May-18 06:02 AM
@swiftbot versions
Avatar
swiftbot BOT 30-May-18 06:02 AM
2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 30-May-18 06:03 AM
あ、さっきのはBotが寝ていたのではなくて、パラメータが違います、です。
Avatar
omochimetaru 30-May-18 06:03 AM
あなるほど
Avatar
Kishikawa Katsumi 30-May-18 06:03 AM
勝手に眠るとかじゃなくてよかった。
@swiftbot $install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Avatar
swiftbot BOT 30-May-18 06:04 AM
install: missing destination file operand after 'swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a' Try 'install --help' for more information.
Avatar
Kishikawa Katsumi 30-May-18 06:05 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Botを介してシェルを叩くのは万能感が味わえて楽しいんだけど、さっさと自動化すべきですね。
Avatar
swiftbot BOT 30-May-18 06:07 AM
Sending build context to Docker daemon 89.91MB Step 1/10 : FROM ubuntu:16.04 ---> f975c5035748 Step 2/10 : LABEL maintainer="Katsumi Kishikawa <kishikawakatsumi@mac.com>" ---> Running in a69bfb9db1ab Removing intermediate container a69bfb9db1ab ---> 5ccd5d03a5fe Step 3/10 : LABEL Description="Docker Container for the Apple's Swift programming language" ---> Running in 21f3976de53e Removing intermediate container 21f3976de53e ---> 91e0694f254e Step 4/10 : RUN apt-get -q update && apt-get -q install -y make libc6-dev clang-3.8 curl libedit-dev libpython2.7 libicu-dev libssl-dev libxml2 tzdata git libcurl4-openssl-dev pkg-config && update-alternatives --quiet --install /usr/bin/clang clang /usr/bin/clang-3.8 100 && update-alternatives --quiet --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100 && rm -r /var/lib/apt/lists/* ---> Running in 0599cc52794a Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.9 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [637 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB] Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [444 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3743 B] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:10 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB] Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB] ...
64.19 KB
Avatar
Kishikawa Katsumi 30-May-18 06:11 AM
@swiftbot versions
Avatar
swiftbot BOT 30-May-18 06:11 AM
2018-05-29-a 2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
omochimetaru 30-May-18 06:11 AM
Avatar
Kishikawa Katsumi 30-May-18 06:11 AM
@omochimetaru はいりました
Avatar
omochimetaru 30-May-18 06:11 AM
@swiftbot --version=2018-05-29-a,4.1.1
protocol P0 { init(string: String) } class Animal { init() {} convenience init(string: String) { self.init() } var str1: String = "" } final class Cat : Animal, P0 { var str2: String = "" } func createP0<X: P0>() -> X { return X.init(string: "apple") } let cat: Cat = createP0() print(cat)
🛠 1
Avatar
swiftbot BOT 30-May-18 06:11 AM
Author icon omochimetaru
protocol P0 { init(string: String) } class Animal { init() {} convenience init(string: String) { self.init() } var str1: String = "" } final class Cat : Animal, P0 { var str2: String = "" } func createP0<X: P0>() -> X { return X.init(string: "apple") } let cat: Cat = createP0() print(cat)
Version:
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Output:
Error:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/IRGen/MetadataLayout.h:208: const swift::irgen::ClassMetadataLayout::StoredMethodInfo &swift::irgen::ClassMetadataLayout::getStoredMethodInfo(swift::SILDeclRef) const: Assertion `it != MethodInfos.end()' failed. /usr/bin/swift[0x40fb264] /usr/bin/swift[0x40f90f2] /usr/bin/swift[0x40fb412] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f549b0bc390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f54997fb428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f54997fd02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f54997f3bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f54997f3c82] /usr/bin/swift[0x625c26] /usr/bin/swift[0x685385] /usr/bin/swift[0x68579b] /usr/bin/swift[0x5f20f5] /usr/bin/swift[0x5e41c8] /usr/bin/swift[0x5e216e] /usr/bin/swift[0x505bcb] /usr/bin/swift[0x5bc277] /usr/bin/swift[0x5baa10] /usr/bin/swift[0x4f6c37] /usr/bin/swift[0x4ddb8b] /usr/bin/swift[0x4d8eb1] ...
Version:
swift-4.1.1-RELEASE
Output:
main.Cat
Error:
Avatar
omochimetaru 30-May-18 06:11 AM
確認できた〜w
0529でコンパイラクラッシュ、4.1.1リリースは大丈夫。
Avatar
norio_nomura 30-May-18 07:10 AM
僕のbotは自動更新されてます。
Avatar
omochimetaru 30-May-18 07:10 AM
@swift-nightly --version (edited)
Avatar
swiftNightly BOT 30-May-18 07:10 AM
Swift version 4.2-dev (LLVM 6a6f279fed, Clang 8c9b467e0e, Swift 1a317f4712) Target: x86_64-unknown-linux-gnu
(edited)
Avatar
omochimetaru 30-May-18 07:11 AM
プレイ中のゲームか
右ペインの幅が足りなくて見切れてるけど右クリックしたら見れた
シングルクリックでもよいか
Avatar
t.ae 30-May-18 07:12 AM
botのロール?あったら見やすくないですか?
Avatar
Avatar
t.ae 30-May-18 07:14 AM
adminのしたあたりにまとまってたらみやすいかなと
Avatar
omochimetaru 30-May-18 07:14 AM
たしかに。システム側でついてる [BOT] とは別で二重になっちゃうけど
やってみた
👍 2
Avatar
norio_nomura 30-May-18 07:16 AM
きしかわさんのbotが漏れてる
Avatar
omochimetaru 30-May-18 07:17 AM
aaa
OK
Avatar
koher 30-May-18 07:21 AM
Discord 再起動したら過去の bot の発言も緑になった。
どうせなら Swift オレンジでもいいかも。↓のオレンジ。 https://swift.org/assets/images/swift.svg
Avatar
omochimetaru 30-May-18 07:24 AM
swiftのbotとは限らないかなと思って。
Avatar
koher 30-May-18 07:24 AM
#EF5138 らしい。
swift-developers-japan の bot だしいいのでは。 (edited)
Avatar
omochimetaru 30-May-18 07:27 AM
やってみた
👍 1
Avatar
Kishikawa Katsumi 30-May-18 07:32 AM
いろいろ機能があるんですね。
ユーザーごとにミュートしたりできるのか。
Avatar
omochimetaru 30-May-18 07:34 AM
ボイスチャットでうるさい人を個人的にミュートしたりできるやつですね
Avatar
Kishikawa Katsumi 30-May-18 07:42 AM
それは合理的ですね。
Avatar
koher 30-May-18 08:00 AM
せっかくやってもらったけど、オレンジは輝度が低すぎてダークテーマだと少し読みづらい?他の人が特に気にならないようなら僕は問題ないですが。
Avatar
Kishikawa Katsumi 01-Jun-18 10:01 AM
MacHostのBotあったら便利かな。ここで使われるくらいの頻度なら家に余ってるMacBookProで動かしても良さそう。
Avatar
koher 01-Jun-18 10:05 AM
うーん、便利か便利でないかで言えばあれば便利だとは思いますが、 Mac は基本的に手元で試せますし、 Bot に実行させたいのは Linux との挙動の違いを動かして共有したい場合くらいなので、なくても(さっきみたいに)結果貼れば十分なような気もします。
Avatar
omochimetaru 01-Jun-18 10:11 AM
手元環境は人によって違うのが微妙で、 信頼できる再現結果としてもbotが便利で、 その点Linuxしか無いのは不便なので、 自分はあったらとても嬉しい。
Avatar
norio_nomura 01-Jun-18 10:46 PM
@swift-4.1.3 -version
Avatar
swift41 BOT 01-Jun-18 10:46 PM
Swift version 4.1.2 (swift-4.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 11-Jun-18 11:33 AM
SwiftBacktraceをインポートできる様にしました。 @swift-4.1.3
import Foundation import SwiftBacktrace handle(signal: SIGABRT) { signo in fputs(backtrace().joined(separator: "\n") + "\nsignal: \(signo)", stderr) fflush(stderr) } abort()
Avatar
swift41 BOT 11-Jun-18 11:33 AM
exit status: 134 with stderr:
/Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(callStackSymbols<A>(_:transform:)+0x87) [0x00007f899fa2d567] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(backtrace(_:formatter:)+0xd8) [0x00007f899fa2ce98] -(+0x0) [0x00007f89a790d175] -(+0x0) [0x00007f89a790d410] /lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x00007f89a74dd390] -(+0x0) [0x00007ffdd962fcb0] signal: 6
Avatar
N. 15-Jun-18 04:17 AM
@swift-4.2.4
do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
Avatar
swift42 BOT 15-Jun-18 04:17 AM
Hello
Avatar
N. 15-Jun-18 04:18 AM
@swiftbot --latest
do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
🛠 1
Avatar
swiftbot BOT 15-Jun-18 04:18 AM
Author icon Ohta
do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
Version:
swift-4.1.1-RELEASE
Output:
Hello
Error:
Avatar
N. 15-Jun-18 04:19 AM
@swift-nightly
do { class A { let title: String init(title: String) { self.title = title } } let a1 = A(title: "Hello") print(a1.title) }
Avatar
swiftNightly BOT 15-Jun-18 04:19 AM
Hello
Avatar
N. 15-Jun-18 04:27 AM
(ふむ。。4.2で問題なく実行されますね。Xcode 10.0 beta の Playground だと class Aを init()したところで error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). になります🤔
Avatar
norio_nomura 15-Jun-18 11:18 AM
Xcode 10 beta 1添付のSwift 4.2でもREPLだと動くので、Xcode 10 beta 1のPlaygroundに問題があるみたいですね。
😀 1
Avatar
N. 18-Jun-18 01:54 AM
ほんとだ。REPLだと問題なく実行されますね。ありがとうございます 🙇 Welcome to Apple Swift version 4.2 (swiftlang-1000.0.16.4 clang-1000.0.25.3). (edited)
Avatar
kateinoigakukun 19-Jun-18 11:32 AM
@swiftbot --version=2018-06-18-a,4.1.1
protocol A { associatedtype C = B } struct B {} struct D<T>: A {} extension D where T: A { typealias C = T.C }
🛠 1
Avatar
swiftbot BOT 19-Jun-18 11:32 AM
Author icon kateinoigakukun
protocol A { associatedtype C = B } struct B {} struct D<T>: A {} extension D where T: A { typealias C = T.C }
Version:
⚠️ 2018-06-18-a
Error:
Swift '2018-06-18-a' toolchain is not supported.
Version:
swift-4.1.1-RELEASE
Output:
Error:
Can't demangle: _T0Xe1C4main1APqaMa /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f80fc8ab390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f80fafea428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f80fafec02a] /usr/bin/swift[0x1752665] /usr/bin/swift[0x17522cf] /usr/bin/swift[0x5f6e5f] /usr/bin/swift[0x5f6527] /usr/bin/swift[0x5f5a18] /usr/bin/swift[0x4e7e2c] /usr/bin/swift[0x4ec855] /usr/bin/swift[0x55017e] /usr/bin/swift[0x53dc74] /usr/bin/swift[0x5783d4] /usr/bin/swift[0x577cbd] /usr/bin/swift[0x56e18d] /usr/bin/swift[0x4e5c60] /usr/bin/swift[0x5ad73f] /usr/bin/swift[0x5abf9d] /usr/bin/swift[0x4d878b] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] /usr/bin/swift[0x4778c4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f80fafd5830] /usr/bin/swift[0x475179] Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret /usercode/main.swift -disable-objc-interop -module-name main ...
Avatar
kateinoigakukun 19-Jun-18 11:33 AM
これはコンパイルできるべき?
Avatar
omochimetaru 19-Jun-18 11:33 AM
変なエラーだ
普通だったらDのconform Aはこのextensionに書きそうなパターンだね (edited)
これ自体が正当なのかはよくわからないけど・・・,
Avatar
kateinoigakukun 19-Jun-18 11:40 AM
struct Path<T1, T2> {} protocol PathConstructorType { associatedtype T1 associatedtype T2 associatedtype PathType = Path<T1, T2> } struct PathConstructor<T1, T2>: PathConstructorType { func create(path: [String]) -> PathType { fatalError() } } extension PathConstructor where T2: PathConstructorType { typealias PathType = Path<T1, T2.PathType> }
実際のコードはこんな感じで、PathConstructor<T1, PathConstructor<T2, T3>>Path<T1, Path<T2, T3>> に変換するために再帰させたいなーと
Avatar
omochimetaru 19-Jun-18 11:45 AM
なんとなく、assoctypeの確定とconformは同時でないといけない気がしている。
Avatar
rintaro 19-Jun-18 11:46 AM
where 付き extensionで associatedtype を上書きですかー。 (edited)
@swiftbot --version=2018-05-29-a,4.1.1
struct A { } struct B { } protocol P { associatedtype Assoc = A } struct S<T>: P { } extension S where T == Int { typealias Assoc = B } print(S<String>.Assoc())
(edited)
🛠 1
Avatar
swiftbot BOT 19-Jun-18 11:46 AM
(edited)
Author icon rintaro
struct A { } struct B { } protocol P { associatedtype Assoc = A } struct S<T>: P { } extension S where T == Int { typealias Assoc = B } print(S<String>.Assoc())
Version:
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Output:
B()
Error:
Version:
swift-4.1.1-RELEASE
Output:
B()
Error:
Avatar
rintaro 19-Jun-18 11:47 AM
うまく動いてないことだけは確かだ。
Avatar
kateinoigakukun 19-Jun-18 11:57 AM
@swiftbot --version=2018-05-29-a,4.1.1
protocol P { typealias Assoc = A } struct A {} struct B: P { typealias Assoc = Int } struct S<T>: P {} extension S where T: P { typealias Assoc = T.Assoc } print(type(of: S<B>.Assoc.self))
(edited)
🛠 1
Avatar
swiftbot BOT 19-Jun-18 11:57 AM
(edited)
Author icon kateinoigakukun
protocol P { typealias Assoc = A } struct A {} struct B: P { typealias Assoc = Int } struct S<T>: P {} extension S where T: P { typealias Assoc = T.Assoc } print(type(of: S<B>.Assoc.self))
Version:
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
Output:
A.Type
Error:
Version:
swift-4.1.1-RELEASE
Output:
A.Type
Error:
Avatar
rintaro 19-Jun-18 12:00 PM
@swift-nightly
protocol P { typealias Assoc = A } struct A {} struct B: P { typealias Assoc = Int } struct S<T>: P {} extension S where T: P { typealias Assoc = T.Assoc } print(type(of: S<B>.Assoc.self))
Avatar
swiftNightly BOT 19-Jun-18 12:00 PM
A.Type
Avatar
rintaro 19-Jun-18 12:02 PM
サポートされるべきか否かはともかく、意図しない動きなのは確かなので、イシュー上げておいたほうが良いと思います。
Avatar
kateinoigakukun 19-Jun-18 12:03 PM
そうですねー。上げておきます。
🙏 1
Parameterized extensionsが入ればprotocolのconformで迂回する必要が無くなるので治るかも
Avatar
koher 20-Jun-18 02:38 AM
@kateinoigakukun
PathConstructor<T1, PathConstructor<T2, T3>>Path<T1, Path<T2, T3>> に変換するために再帰させたいなーと
本来やりたいのは↓のようなことということですか?
struct Path<T1, T2> {} struct PathConstructor<T1, T2> { func create(path: [String]) -> Path<T1, T2> { fatalError() } } extension<T3, T4> PathConstructor where T2 == PathConstructor<T3, T4> { func create(path: [String]) -> Path<T1, Path<T3, T4>> { fatalError() } }
Avatar
kateinoigakukun 20-Jun-18 03:52 AM
@koher ちょっと僕の言葉が足りてなかったです。 Tnまで再帰させたかったんで、parameterized exを使うとこんな感じです
struct Path<T1, T2> {} struct PathConstructor<T1, T2> { typealias PathType = Path<T1, T2> } extension<T3, T4> PathConstructor where T2 == PathConstructor<T3, T4> { typealias PathType = Path<T1, T2.PathType> } extension PathConstructor { func create(path: [String]) -> PathType { fatalError() } }
(edited)
あー、extension でtypealias 上書き出来ないか
Avatar
koher 20-Jun-18 04:04 AM
@kateinoigakukun 最近、 Parameterized Extension が必要と思われていたものが、なしで実装できたケースがあったのでもしかしたらと思ったんですが・・・。 @swiftbot
extension Optional { func flatten<T>() -> T? where Wrapped == T? { return flatMap { $0 } } } let a: Int?? = .some(.some(42)) let b: Int? = a.flatten() print(String(describing: b))
(edited)
🛠 1
Avatar
swiftbot BOT 20-Jun-18 04:04 AM
(edited)
Author icon koher
extension Optional { func flatten<T>() -> T? where Wrapped == T? { return flatMap { $0 } } } let a: Int?? = .some(.some(42)) let b: Int? = a.flatten() print(String(describing: b))
Version:
swift-4.1.1-RELEASE
Output:
Optional(42)
Error:
Avatar
kateinoigakukun 20-Jun-18 05:11 AM
@koher ジェネリスメソッドのwhere句で回避できるんですね。
よくよく考えたら今回の問題はparameterized extension ではなくて、型条件によってtypealiasの宣言の形を切り替えられるようにならないといけないのかもしれないです (edited)
@swiftbot
struct A<T> { } extension A where T == Bool { typealias B = String } extension A { typealias B = Int }
🛠 1
Avatar
swiftbot BOT 20-Jun-18 05:15 AM
Author icon kateinoigakukun
struct A<T> { } extension A where T == Bool { typealias B = String } extension A { typealias B = Int }
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:7:13: error: invalid redeclaration of 'B' typealias B = Int ^ /usercode/main.swift:4:13: note: 'B' previously declared here typealias B = String ^
Avatar
kateinoigakukun 20-Jun-18 05:15 AM
要はこれが通るようになってほしいという話でした
Avatar
tarunon 20-Jun-18 05:16 AM
それでいうとそもそもprotocol+assoctypeをもう一個外側に定義しないとだめだと思う
genericsでtypealias切り替えはちょっと無理筋
っぽい
Avatar
kateinoigakukun 20-Jun-18 05:22 AM
@swiftbot
protocol P { associatedtype T1 associatedtype T2 } extension P where T1 == Int { typealias T2 = String } struct A<T>: P { typealias T1 = T } print(A<String>.T2.self)
🛠 1
Avatar
swiftbot BOT 20-Jun-18 05:22 AM
Author icon kateinoigakukun
protocol P { associatedtype T1 associatedtype T2 } extension P where T1 == Int { typealias T2 = String } struct A<T>: P { typealias T1 = T } print(A<String>.T2.self)
Version:
swift-4.1.1-RELEASE
Output:
String
Error:
Avatar
kateinoigakukun 20-Jun-18 05:22 AM
@tarunon こういうことですか?
Avatar
tarunon 20-Jun-18 05:24 AM
T2を定義する型は分離しておいて、A: HasT2 where T == Intかな
Avatar
kateinoigakukun 20-Jun-18 05:31 AM
@swiftbot
protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } print(A<String>.T2.self)
🛠 1
Avatar
swiftbot BOT 20-Jun-18 05:31 AM
Author icon kateinoigakukun
protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } print(A<String>.T2.self)
Version:
swift-4.1.1-RELEASE
Output:
String
Error:
Avatar
kateinoigakukun 20-Jun-18 05:31 AM
なんじゃこりゃ
Avatar
tarunon 20-Jun-18 05:31 AM
あれ、何これは、、、
Avatar
kateinoigakukun 20-Jun-18 05:32 AM
@swiftbot
protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } func f<A: HasT2>(_ a: A.Type) {} f(A<String>.self)
🛠 1
Avatar
swiftbot BOT 20-Jun-18 05:32 AM
Author icon kateinoigakukun
protocol P { associatedtype T1 } protocol HasT2 { associatedtype T2 } struct A<T>: P { typealias T1 = T } extension A: HasT2 where T == Int { typealias T2 = String } func f<A: HasT2>(_ a: A.Type) {} f(A<String>.self)
Version:
swift-4.1.1-RELEASE
Output:
Error:
/usercode/main.swift:15:1: error: 'String' is not convertible to 'Int' f(A<String>.self) ^
Avatar
kateinoigakukun 20-Jun-18 05:32 AM
これは正しい
Avatar
kateinoigakukun 20-Jun-18 05:39 AM
where無視してtypealiasが生えてる?
あー、だからwhereの条件下のみで使える型をtypealiasに使うとコンパイラクラッシュするのか 昨日のrintaroさんのコードの意図読み間違えてたな (edited)
Avatar
tarunon 20-Jun-18 05:54 AM
@swift-4.2.4
protocol A { associatedtype X } protocol B { associatedtype Y } protocol C { associatedtype Y } struct M<T>: A { typealias X = T } extension M: B where X == Int { typealias Y = Int } extension M: C where X == String { typealias Y = String }
Avatar
swift42 BOT 20-Jun-18 05:54 AM
exit status: 1 with stderr:
<stdin>:21:15: error: invalid redeclaration of 'Y' typealias Y = String ^ <stdin>:17:15: note: 'Y' previously declared here typealias Y = Int ^ <stdin>:16:1: error: type 'M<T>' does not conform to protocol 'B' extension M: B where X == Int { ^ <stdin>:5:20: note: multiple matching types named 'Y' associatedtype Y ^ <stdin>:17:15: note: possibly intended match typealias Y = Int ^ <stdin>:21:15: note: possibly intended match typealias Y = String ^ <stdin>:20:1: error: type 'M<T>' does not conform to protocol 'C' extension M: C where X == String { ^ <stdin>:9:20: note: multiple matching types named 'Y' associatedtype Y ^ <stdin>:17:15: note: possibly intended match typealias Y = Int ^ <stdin>:21:15: note: possibly intended match typealias Y = String ^
Avatar
tarunon 20-Jun-18 05:54 AM
だめなんやなぁ
根っこから具体型分けるのが健全すね
仕方ない
Avatar
t.ae 25-Jun-18 04:38 AM
@swift-4.2.4
let a: Float80 = 0
Avatar
swift42 BOT 25-Jun-18 04:38 AM
no output
Avatar
norio_nomura 27-Jun-18 03:27 AM
コンパイラクラッシュ https://bugs.swift.org/browse/SR-8119 で更新できていなかったnightlyを久しぶりに更新。 @swift-nightly
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swiftNightly BOT 27-Jun-18 03:27 AM
DEVELOPMENT-SNAPSHOT-2018-06-26-a
Avatar
takka 30-Jun-18 10:29 AM
@swift-4.1.3
Avatar
swift41 BOT 30-Jun-18 10:29 AM
Usage: @swift41 [SWIFT_OPTIONS] `​`​`​ [Swift Code] `​`​`​
Avatar
takka 30-Jun-18 10:33 AM
@swift-4.1.3
import Foundation var formatter = ISO8601DateFormatter() formatter.formatOptions = .withFullDate let date = formatter.date(from: "2018-06-30") print(date)
Avatar
swift41 BOT 30-Jun-18 10:33 AM
Optional(2018-06-30 00:00:00 +0000)
stderr:
<stdin>:5:7: warning: expression implicitly coerced from 'Date?' to Any print(date) ^~~~ <stdin>:5:7: note: provide a default value to avoid this warning print(date) ^~~~ ?? <#default value#> <stdin>:5:7: note: force-unwrap the value to avoid this warning print(date) ^~~~ ! <stdin>:5:7: note: explicitly cast to Any with 'as Any' to silence this warning print(date) ^~~~ as Any
Avatar
d_date 03-Jul-18 05:23 AM
@swift-4.1.3
class A { init() {} convenience init(s: String) { print(self.init()) } }
(edited)
Avatar
swift41 BOT 03-Jul-18 05:23 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/Sema/CSApply.cpp:5684: swift::Expr *(anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr *, swift::AnyFunctionType *, swift::ApplyExpr *, ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder): Assertion `fromTupleExpr.size() == 1 && fromTupleExpr[0]' failed. #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007f4f34d07390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f4f33446428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f4f3344802a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f4f3343ebd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #6 0x00007f4f3343ec82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #7 0x0000000001399d4e (anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr*, swift::AnyFunctionType*, swift::ApplyExpr*, llvm::ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder) (/usr/bin/swift+0x1399d4e) #8 0x0000000001383604 (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) (/usr/bin/swift+0x1383604) #9 0x000000000139b0e3 (anonymous namespace)::ExprRewriter::visitApplyExpr(swift::ApplyExpr*) (/usr/bin/swift+0x139b0e3) #10 0x000000000137fbd4 (anonymous namespace)::ExprRewriter::walkToExprPost(swift::Expr*) (/usr/bin/swift+0x137fbd4) #11 0x0000000001385621 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) (/usr/bin/swift+0x1385621) #12 0x000000000167719c swift::Expr::walk(swift::ASTWalker&) (/usr/bin/swift+0x167719c) #13 0x000000000137c7ef swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) (/usr/bin/swift+0x137c7ef) #14 0x00000000012c64b6
(edited)
Avatar
Kishikawa Katsumi 03-Jul-18 05:24 AM
@swiftbot !install swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-02-a
Avatar
swiftbot BOT 03-Jul-18 05:30 AM
The command '/bin/sh -c SWIFT_URL=https://swift.org/builds/$SWIFT_BRANCH/$(echo "$SWIFT_PLATFORM" | tr -d .)/$SWIFT_VERSION/$SWIFT_VERSION-$SWIFT_PLATFORM.tar.gz && curl -fSsL $SWIFT_URL -o swift.tar.gz && curl -fSsL $SWIFT_URL.sig -o swift.tar.gz.sig && export GNUPGHOME="$(mktemp -d)" && tar -xzf swift.tar.gz --directory / --strip-components=1 && rm -r "$GNUPGHOME" swift.tar.gz.sig swift.tar.gz && chmod -R o+r /usr/lib/swift' returned a non-zero code: 22
Avatar
Kishikawa Katsumi 03-Jul-18 05:31 AM
@swiftbot versions
Avatar
swiftbot BOT 03-Jul-18 05:31 AM
2018-05-29-a 2018-05-08-a 2018-05-02-a 2018-04-25-a 2018-04-23-a 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 03-Jul-18 05:32 AM
@swiftbot
public func p(_ items: Any...) {} class A { init() {} convenience init(s: String) { p(self.init()) } }
🛠 1
Avatar
swiftbot BOT 03-Jul-18 05:32 AM
Author icon kishikawakatsumi
public func p(_ items: Any...) {} class A { init() {} convenience init(s: String) { p(self.init()) } }
Version:
swift-4.1.1-RELEASE
Output:
Error:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/Sema/CSApply.cpp:5684: swift::Expr *(anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr *, swift::AnyFunctionType *, swift::ApplyExpr *, ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder): Assertion `fromTupleExpr.size() == 1 && fromTupleExpr[0]' failed. /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f167dc3e390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f167c37d428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f167c37f02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f167c375bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f167c375c82] /usr/bin/swift[0x1399b2e] /usr/bin/swift[0x13833e4] /usr/bin/swift[0x139aec3] /usr/bin/swift[0x137f9b4] /usr/bin/swift[0x1385401] /usr/bin/swift[0x1676f7c] /usr/bin/swift[0x137c5cf] /usr/bin/swift[0x12c6296] /usr/bin/swift[0x1355fd6] ...
Avatar
Kishikawa Katsumi 03-Jul-18 05:33 AM
久しぶりにコンパイラのバグを見つけた。
Avatar
rintaro 03-Jul-18 08:03 AM
For (previously crashing): class A { init() {} convenience init(s: String) { print(self.init()) } } target of RebindSelfInConstructorExpr should be call expression self.init() ...
Avatar
Kishikawa Katsumi 03-Jul-18 08:09 AM
まさかレポートする前に直るとは 🤣
self.init()の戻り値を変数に受けられないっていうの初めて知ったんですよね。
Avatar
rintaro 03-Jul-18 08:14 AM
type checker 上では リターンタイプは Void として扱われていますね。
Avatar
N. 04-Jul-18 07:41 AM
@swiftbot import Foundation print("Good night") sleep(1) print("Morning")
あれ、これダメでしたか😵 🙇
Avatar
omochimetaru 04-Jul-18 07:43 AM
バッククォート3つではさみます。
😃 1
Avatar
t.ae 04-Jul-18 07:43 AM
+swift
😃 1
Avatar
Kishikawa Katsumi 04-Jul-18 07:43 AM
swiftはなくてもOKになりました。 (edited)
😲 1
Avatar
N. 04-Jul-18 07:44 AM
@swiftbot ではswiftなしで。
import Foundation print("Good night") sleep(1) print("Morning")
🛠 1
Avatar
swiftbot BOT 04-Jul-18 07:44 AM
Author icon Ohta
import Foundation print("Good night") sleep(1) print("Morning")
Version:
swift-4.1.1-RELEASE
Output:
Good night Morning
Error:
Avatar
Kishikawa Katsumi 04-Jul-18 07:45 AM
sleepは実行結果だけ見るとわからないですね。
Playgroundみたいに1行1行について実行した結果のデータを見られるとおもしろいんですけど。
Avatar
N. 04-Jul-18 07:46 AM
@swiftbot
import Foundation //import PlaygroundSupport //PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") //PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */
🛠 1
Avatar
swiftbot BOT 04-Jul-18 07:46 AM
Author icon Ohta
import Foundation //import PlaygroundSupport //PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") //PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */
Version:
swift-4.1.1-RELEASE
Output:
Good night, Anna.. Good night, Bob..
Error:
Avatar
N. 04-Jul-18 07:50 AM
Sleep(2) では時間切れになってしまうようですね😅
import Foundation import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true let group1 = DispatchGroup() func a(_ name: String) { group1.enter() print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } DispatchQueue.global().async { a("Anna") } DispatchQueue.global().async { a("Bob") } DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") PlaygroundPage.current.finishExecution() } // Xcode 9.4.1 と 10.0 beta2 どちらも同じ結果でした /* Playground Settings - Platform: macOS Good night, Cony.. Good night, Anna.. Good night, Bob.. Morning, Cony! Morning, Bob! Morning, Anna! *** Good morning, all! *** */ /* Playground Settings - Platform: iOS Good night, Anna.. Good night, Cony.. Good night, Bob.. *** Good morning, all! *** */
上記のコードを Playgroundで実行すると、Platformによって実行結果が変わってしまいます。macOSにすると望む結果になるんですけど、iOSだと待ち合わせしてくれないのです。
(edited)
Avatar
omochimetaru 04-Jul-18 07:50 AM
@N. notifyって、そのグループのenter数が1->0になるタイミングを待つんじゃないですかね?
そのコードだと、関数aの呼び出しがグローバルキューに投げられているので、
あいや、いいのか、sleepしているから、必ず3つのenterが先行しているんですね。
1つめのenterよりもはやくnotifyして即抜けしているけど
printの前後順だけはすり替わってる?
@swiftbot
import Foundation let group1 = DispatchGroup() group1.notify(queue: .main) { print("*** Good morning, all! ***") } sleep(1)
(edited)
🛠 1
Avatar
swiftbot BOT 04-Jul-18 07:55 AM
(edited)
Author icon omochimetaru
import Foundation let group1 = DispatchGroup() group1.notify(queue: .main) { print("*** Good morning, all! ***") } sleep(1)
Version:
swift-4.1.1-RELEASE
Output:
Error:
Avatar
omochimetaru 04-Jul-18 07:57 AM
@swiftbot
import Foundation let task = DispatchQueue(label: "task") let group1 = DispatchGroup() group1.notify(queue: task) { print("*** Good morning, all! ***") } sleep(1)
🛠 1
Avatar
swiftbot BOT 04-Jul-18 07:57 AM
Author icon omochimetaru
import Foundation let task = DispatchQueue(label: "task") let group1 = DispatchGroup() group1.notify(queue: task) { print("*** Good morning, all! ***") } sleep(1)
Version:
swift-4.1.1-RELEASE
Output:
*** Good morning, all! ***
Error:
Avatar
omochimetaru 04-Jul-18 07:58 AM
@N. 多分起きているのは↑こういうことだと思います。 1つ目のenterよりも先にnotifyしていて、即座に実行されている
Avatar
N. 04-Jul-18 07:58 AM
😨 ??
Avatar
omochimetaru 04-Jul-18 07:59 AM
3つのenterのあとで、notifyが呼ばれる必要があると思います。 (edited)
🙇 1
Avatar
N. 04-Jul-18 07:59 AM
あー😵
ありがとうございます!
そうか、enter --> notify の順に書いたつもりだけど、enterは async ブロックの中に置いてあるから後で実行される可能性があるのか。。。
Avatar
omochimetaru 04-Jul-18 08:02 AM
はい。
Avatar
N. 04-Jul-18 08:02 AM
なので、iOSかmacOSか によって実行結果が変わったのか。。
Avatar
omochimetaru 04-Jul-18 08:03 AM
そこのスケジューリングの運によって変わったようですね
Avatar
N. 04-Jul-18 08:04 AM
なるほどー。 実は複雑になるので述べなかったのですが、tvOSを選択すると結果が様々に(iOS的だったりmacOS的だったり)なっていたのです。
@omochimetaru ありがとうございます😃
Avatar
omochimetaru 04-Jul-18 08:04 AM
import Foundation let group1 = DispatchGroup() func a(_ name: String) { print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") group1.leave() } group1.enter() DispatchQueue.global().async { a("Anna") } group1.enter() DispatchQueue.global().async { a("Bob") } group1.enter() DispatchQueue.global().async { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") }
↑これでいつも期待した挙動に。
これ合法なのかよくわかんないですけど・・・
Avatar
N. 04-Jul-18 08:08 AM
@omochimetaru 😃 👍
✌ 1
Avatar
norio_nomura 04-Jul-18 10:51 AM
@swift-4.1.3
import Foundation let group1 = DispatchGroup() func a(_ name: String) { print("Good night, \(name)..") sleep(2) print("Morning, \(name)!") } DispatchQueue.global().async(group: group1) { a("Anna") } DispatchQueue.global().async(group: group1) { a("Bob") } DispatchQueue.global().async(group: group1) { a("Cony") } group1.notify(queue: .main) { print("*** Good morning, all! ***") exit(0) } dispatchMain()
Avatar
swift41 BOT 04-Jul-18 10:51 AM
Good night, Anna.. Good night, Bob.. Good night, Cony.. Morning, Anna! Morning, Bob! Morning, Cony! *** Good morning, all! ***
Avatar
omochimetaru 04-Jul-18 11:14 AM
async(group:)というのがあるのか!
Avatar
N. 05-Jul-18 12:59 AM
おー!😃 @norio_nomura ありがとうございます。
👍 1
話が少しずれるんですけど、https://developer.apple.com/search/?q=async で検索してみたら、、、 (edited)
Search - Developer
こんな感じで Videoの中を検索してくれるようです。知らなかった。しかも asynchronous と発語されたところから再生できるのか。すごい😃 (edited)
Avatar
N. 05-Jul-18 01:11 AM
async(group:execute:)は iOS 8から存在してました😅 https://developer.apple.com/documentation/dispatch/dispatchqueue/2300095-async (edited)
Avatar
omochimetaru 05-Jul-18 04:57 AM
DispatchGroupのenterとleaveの説明が explicitly って書いてあったから
implicitlyなやり方があるんだろうなと思ったけど、DispatchGroupのドキュメントには見つからなかったのは
DispatchQueueの方のメソッドだったからだった。
😀 1
Avatar
d_date 06-Jul-18 08:00 AM
あなたの会社のSlackでもSwiftbotがつくれる by @Nonchalant https://github.com/Nonchalant/SwiftBot
SwiftBot - Execute Swift on Slack
swift 2
Avatar
Kishikawa Katsumi 06-Jul-18 08:01 AM
^ めっちゃシンプルなコードで実現されている😍
Avatar
norio_nomura 06-Jul-18 10:42 AM
コードを見ると、ユーザーがSLACK_BOT_TOKENとか簡単に取得できそうだけど大丈夫なのかな… (edited)
Avatar
Kishikawa Katsumi 06-Jul-18 11:05 AM
とりあえず会社内でしか使わない前提ですよね。
Avatar
Nonchalant 06-Jul-18 11:17 AM
その前提ですね!swiftを経由してシェルコマンドとかも呼べちゃうので脆弱性に関しては目をつぶってる感じです...
Avatar
norio_nomura 06-Jul-18 11:32 AM
なるほど。
Avatar
norio_nomura 06-Jul-18 11:56 AM
もしかして、Slackの場合アカウントがサーバー毎に分かれてるから、勝手に他所のサーバーへ招かれる心配が少ないのかな。
Avatar
Kishikawa Katsumi 06-Jul-18 12:54 PM
最近のSlackBotはすごいリッチなUIを返したりできるっぽくて、パラメータとか工夫しなくても便利にできそうなんですよね。
なんかドロップダウンリストを表示したりできるらしい。
Avatar
norio_nomura 06-Jul-18 01:25 PM
勝手に他所のサーバーへ招かれる心配が少ないのかな。
Discordの場合、アバター画像URLに含まれるユーザーIDを使って他のサーバーへ招待できてしまう。
Avatar
Kishikawa Katsumi 06-Jul-18 01:27 PM
Botじゃなくて普通のユーザーを、ってことですか?
Botは無理ですよね。
Avatar
norio_nomura 06-Jul-18 01:37 PM
きしかわさんのswiftbotを僕がボットを追加可能なサーバーへ招待する画面。
🙄 1
公開botにしてなければ出来ないのかな?
Avatar
Kishikawa Katsumi 06-Jul-18 01:41 PM
Botはトークンを知らないとダメだと思ってましたけど、いらないんですね。
Avatar
norio_nomura 20-Jul-18 03:19 AM
swift-nightlyとswift-tensorflowはPackageDescription API v3の廃止によりビルド出来なくなり、更新が止まっています。
🙄 1
どの様に対処するか思案中。
Avatar
d_date 20-Jul-18 06:58 AM
@swift-4.2.4
let wat: Int? = nil if let _: Int? = wat { print("1") } if let _: Any? = wat { print("2") }
Avatar
swift42 BOT 20-Jul-18 06:58 AM
1
stderr:
<stdin>:2:4: warning: explicitly specified type 'Int?' adds an additional level of optional to the initializer, making the optional check always succeed if let _: Int? = wat { print("1") } ^ ~~~~ ~~~ Int
Avatar
omochimetaru 20-Jul-18 07:00 AM
2つ目の解釈変じゃない?
Avatar
d_date 20-Jul-18 07:03 AM
Amazingly, 23% of people got the correct answer: it only prints 1. * The 1st condition succeeds because wat is implicitly promoted to Int?? (with a nice compiler warning) * The 2nd condition fails because… uh… it doesn’t get promoted this time, eh? Hm. https://t.co/f...
Avatar
omochimetaru 20-Jul-18 07:03 AM
なるほど・・・
23%の人すごいね。
Avatar
d_date 20-Jul-18 07:06 AM
2の事象に気づいていたのか、適当なのかはわからんけどw
Avatar
norio_nomura 21-Jul-18 11:57 AM
swift-nightlyとswift-tensorflow復活。 @swift-nightly
enum Result<Value, Error> { case success(Value) case failure(Error) } extension Result: Equatable where Value: Equatable, Error: Equatable { static func == (lhs: Result, rhs: Result) -> Bool { switch (lhs, rhs) { case let (.success(lhs), .success(rhs)): return lhs == rhs case let (.failure(lhs), .failure(rhs)): return lhs == rhs case (.success, .failure), (.failure, .success): return false } } } print(Result<String, Never>.success("a") == Result<String, Never>.success("b"))
swift 1
Avatar
swiftNightly BOT 21-Jul-18 11:57 AM
false
Avatar
norio_nomura 21-Jul-18 11:59 AM
@swift-nightly @swift-tensorflow
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"] ?? "")
Avatar
swiftNightly BOT 21-Jul-18 11:59 AM
DEVELOPMENT-SNAPSHOT-2018-07-20-a
Avatar
swiftTensorflow BOT 21-Jul-18 11:59 AM
DEVELOPMENT-2018-07-19-a
Avatar
norio_nomura 24-Jul-18 12:50 AM
rdar://problem/40916953 @swift-4.1.3 @swift-4.2.4 -suppress-warnings
struct ConditionalCast<T> { static func cast(value: Any?) -> T? { return value as? T } } print(ConditionalCast<Int?>.cast(value: nil))
Avatar
swift41 BOT 24-Jul-18 12:50 AM
nil
Avatar
swift42 BOT 24-Jul-18 12:50 AM
Optional(nil)
Avatar
tarunon 24-Jul-18 01:35 AM
これはどっちに転けても正しそう
Avatar
norio_nomura 24-Jul-18 04:43 AM
New in Xcode 10 beta 4 – Swift and Apple Clang Compilersに記載された挙動です。
Avatar
swift41 BOT 28-Jul-18 02:40 AM
4.1.3-RELEASE
Avatar
kateinoigakukun 07-Aug-18 09:36 AM
@swift-4.1.3
class Object { func foo() -> String { return "from Object" } } class Child: Object { override func foo() -> String { return "from Child" } } let child = unsafeBitCast(Object(), to: Child.self) print(child.foo())
Avatar
swift41 BOT 07-Aug-18 09:36 AM
from Child
stderr:
<stdin>:12:13: warning: 'unsafeBitCast' from 'Object' to 'Child' can be replaced with 'unsafeDowncast' let child = unsafeBitCast(Object(), to: Child.self) ^~~~~~~~~~~~~ unsafeDowncast
Avatar
tarunon 07-Aug-18 09:37 AM
え、、
Avatar
Kishikawa Katsumi 07-Aug-18 09:37 AM
なんか増えとる。
Avatar
omochimetaru 07-Aug-18 09:37 AM
あるね
Avatar
kateinoigakukun 07-Aug-18 09:37 AM
childの型がコンパイル時に決まると最適化でこうなる
dynamic typeか
Avatar
Kishikawa Katsumi 07-Aug-18 09:37 AM
へえ。
Avatar
d_date 08-Aug-18 06:10 AM
4.1.3出たのはいいけど、対応するXcodeがないんだよなぁ
Avatar
Kishikawa Katsumi 08-Aug-18 06:14 AM
4.1.3はLinuxOnlyじゃなかったっけ
😃 1
Avatar
d_date 08-Aug-18 06:18 AM
あ、ほんとだ
*Swift 4.1.3 is Linux only change, Swift 4.1.2 is available as part of Xcode 9.4.
😃 1
Avatar
norio_nomura 10-Aug-18 04:03 AM
@swift-4.1.3 @swift-nightly -Xfrontend -print-ast
func f(a: Int = 1){}
Avatar
swift41 BOT 10-Aug-18 04:03 AM
internal func f(a: Int = default)
Avatar
swiftNightly BOT 10-Aug-18 04:03 AM
internal func f(a: Int = 1)
Avatar
t.ae 10-Aug-18 04:05 AM
お、値見えるようになるんですかね
Avatar
omochimetaru 10-Aug-18 04:06 AM
rintaro昨日 午後4時15分 https://github.com/apple/swift/pull/18579 これは嬉しい!インターフェイスでデフォルト値が default じゃなくてきちんと表示されるようになります。
Avatar
norio_nomura 10-Aug-18 04:07 AM
それです。
Avatar
omochimetaru 10-Aug-18 04:35 AM
-print-ast が対応してるんですね
Avatar
nekonoki 13-Aug-18 10:09 AM
@swift-4.2.4 @swift-nightly
class Super<T> {} class Sub: Super<Sub> {} print(Sub())
(edited)
Avatar
swiftNightly BOT 13-Aug-18 10:11 AM
execution timeout with no output
Avatar
swift42 BOT 13-Aug-18 10:11 AM
execution timeout with no output
Avatar
kateinoigakukun 16-Aug-18 04:39 AM
@swift-4.0.3
protocol Animal {} extension Animal { init(_animal: Self) { self = _animal } } class AnimalBase: Animal { convenience init(with animal: AnimalBase) { self.init(_animal: animal) } } class Cat: AnimalBase { let _name = "Tama" var name: String { return _name } func bark() { print("cat \(self.name)") } } class Dog: AnimalBase {} let animal = Cat(with: Dog()) animal.bark()
(edited)
Avatar
swift40 BOT 16-Aug-18 04:39 AM
exit status: 11 with stderr:
#0 0x0000000003ae91b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/swift+0x3ae91b8) #1 0x0000000003ae98f6 SignalHandler(int) (/usr/bin/swift+0x3ae98f6) #2 0x00007fa453580390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007fa44ed5824f _swift_retain_ (/usr/lib/swift/linux/libswiftCore.so+0x41324f) #4 0x00007fa4539af2f9 #5 0x00007fa4539af405 #6 0x00007fa4539af06b #7 0x0000000000f348bf llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0xf348bf) #8 0x0000000000f38a62 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/usr/bin/swift+0xf38a62) #9 0x00000000004bf776 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) (/usr/bin/swift+0x4bf776) #10 0x00000000004ae580 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) (/usr/bin/swift+0x4ae580) #11 0x00000000004aa52b swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift+0x4aa52b) #12 0x0000000000465564 main (/usr/bin/swift+0x465564) #13 0x00007fa451caa830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830) #14 0x0000000000462e29 _start (/usr/bin/swift+0x462e29) Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/engine.git--3106915580378752918/Sources/CHTTP/inc
(edited)
Avatar
kateinoigakukun 16-Aug-18 04:43 AM
やっぱり self.init(_animal: animal) が通るのヤバですね
Avatar
omochimetaru 16-Aug-18 05:19 AM
うむ〜
Avatar
omochimetaru 16-Aug-18 06:59 AM
@swiftbot
fatalError()
🛠 1
Avatar
swiftbot BOT 16-Aug-18 06:59 AM
Author icon omochimetaru
fatalError()
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: file /usercode/main.swift, line 1 Current stack trace: 0 libswiftCore.so 0x00007f64e85c55c0 _swift_stdlib_reportFatalErrorInFile + 221 1 libswiftCore.so 0x00007f64e83343dc <unavailable> + 1369052 2 libswiftCore.so 0x00007f64e856e222 <unavailable> + 3703330 3 libswiftCore.so 0x00007f64e856f689 <unavailable> + 3708553 4 libswiftCore.so 0x00007f64e8333ad6 <unavailable> + 1366742 5 libswiftCore.so 0x00007f64e856dfeb <unavailable> + 3702763 6 libswiftCore.so 0x00007f64e8333ad6 <unavailable> + 1366742 7 libswiftCore.so 0x00007f64e84a0f79 <unavailable> + 2862969 8 libswiftCore.so 0x00007f64e8333440 _assertionFailure(_:_:file:line:flags:) + 44 10 swift 0x0000000000fed1ce <unavailable> + 12505550 ...
Avatar
omochimetaru 16-Aug-18 06:59 AM
@swiftbot
import Foundation "".enumerateLines { (a, b) in }
🛠 1
Avatar
swiftbot BOT 16-Aug-18 06:59 AM
Author icon omochimetaru
import Foundation "".enumerateLines { (a, b) in }
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: enumerateSubstrings(in:options:using:) is not yet implemented: file Foundation/NSString.swift, line 791 /usr/bin/swift[0x3f24d64] /usr/bin/swift[0x3f250a6] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f1619b01390] /usr/lib/swift/linux/libswiftCore.so(+0x2baf79)[0x7f1614d3ff79] /usr/lib/swift/linux/libswiftCore.so(_T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstF+0x2c)[0x7f1614bd246c] /usr/lib/swift/linux/libFoundation.so(+0x50438f)[0x7f160ddd538f] /usr/lib/swift/linux/libFoundation.so(+0x50425a)[0x7f160ddd525a] /usr/lib/swift/linux/libFoundation.so(_T010Foundation8NSStringC14enumerateLinesyySS_SpyAA8ObjCBoolVGtcF+0x77)[0x7f160de63117] /usr/lib/swift/linux/libFoundation.so(_T0s14StringProtocolP10FoundationSS5IndexVADRtzrlE14enumerateLinesyySS_Sbztc8invoking_tF+0xa0)[0x7f160de79620] [0x7f1619f310c3] /usr/bin/swift[0xfed1ce] /usr/bin/swift[0xff1692] /usr/bin/swift[0x4d9076] /usr/bin/swift[0x4c35d3] /usr/bin/swift[0x4beecc] ...
Avatar
ikesyo 18-Aug-18 05:55 AM
@swift-4.0.3
class Person { var name: String var friends: [Person] = [] var bestFriend: Person? = nil init(name: String) { self.name = name } } _ = \Person.bestFriend?.name
Avatar
swift40 BOT 18-Aug-18 05:55 AM
no output
Avatar
ikesyo 18-Aug-18 06:23 AM
@swiftbot --version=4.0
class Person { var name: String var friends: [Person] = [] var bestFriend: Person? = nil init(name: String) { self.name = name } } _ = \Person.bestFriend?.name
🛠 1
Avatar
swiftbot BOT 18-Aug-18 06:23 AM
Author icon ikesyo
class Person { var name: String var friends: [Person] = [] var bestFriend: Person? = nil init(name: String) { self.name = name } } _ = \Person.bestFriend?.name
Version:
swift-4.0-RELEASE
Output:
Error:
Avatar
norio_nomura 28-Aug-18 05:01 AM
-Xfrontendではなく-frontendが使える様になりました。 @swift-4.2.4 -frontend -print-ast
func f(n: Int = 1) {}
Avatar
swift42 BOT 28-Aug-18 05:01 AM
internal func f(n: Int = default)
Avatar
norio_nomura 28-Aug-18 05:02 AM
さらに-frontend -replも使える様になりました。 @swift-4.2.4 -frontend -repl
import RxSwift :print_decl Observable
Avatar
swift42 BOT 28-Aug-18 05:02 AM
class Observable<Element> : ObservableType { typealias E = Element init() func subscribe<O>(_ observer: O) -> Disposable where Element == O.E, O : ObserverType func asObservable() -> Observable<Observable<Element>.E> @objc deinit func composeMap<R>(_ transform: @escaping (Element) throws -> R) -> Observable<R> } extension Observable { @available(*, deprecated, renamed: "from(optional:)", message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.") static func from(_ optional: Observable<Element>.E?) -> Observable<Observable<Element>.E> @available(*, deprecated, renamed: "from(optional:scheduler:)", message: "Implicit conversions from any type to optional type are allowed and that is causing issues with `from` operator overloading.") static func from(_ optional: Observable<Element>.E?, scheduler: ImmediateSchedulerType) -> Observable<Observable<Element>.E> }
Avatar
norio_nomura 28-Aug-18 05:03 AM
@swift-4.1.3 @swift-4.2.4 -frontend -repl
:print_decl Hashable
(edited)
Avatar
swift42 BOT 28-Aug-18 05:03 AM
protocol Hashable : Equatable { var hashValue: Int { get } func hash(into hasher: inout Hasher) }
(edited)
Avatar
swift41 BOT 28-Aug-18 05:05 AM
protocol Hashable : Equatable { var hashValue: Int { get } }
Avatar
bannzai 04-Sep-18 07:07 AM
@swiftbot help
Avatar
swiftbot BOT 04-Sep-18 07:07 AM
Usage: @swiftbot [--version=SWIFT_VERSION] [--command={swift, swiftc}] [--options=SWIFTC_OPTIONS] `​`​` [Swift Code] `​`​` Examples: @swiftbot `​`​` print("Hello world!") `​`​` @swiftbot --version=4.0.3 `​`​` print("Hello world!") `​`​` @swiftbot --command=swiftc --options=-dump-parse `​`​` print("Hello world!") `​`​` Subcommands: @swiftbot versions: show available Swift toolchain versions @swiftbot contribute: show repository URLs @swiftbot help: show help
Avatar
bannzai 04-Sep-18 07:07 AM
@swiftbot --version=4.2
print("hello")
🛠 1
Avatar
swiftbot BOT 04-Sep-18 07:07 AM
Author icon bannzai
print("hello")
Version:
⚠️ 4.2
Error:
Swift '4.2' toolchain is not supported.
Avatar
Kishikawa Katsumi 04-Sep-18 07:08 AM
すまぬ
のむらさんの方は使えるはず
Avatar
bannzai 04-Sep-18 07:08 AM
+👍
@swift-4.2.4
print("hello")
Avatar
swift42 BOT 04-Sep-18 07:08 AM
hello
Avatar
bannzai 04-Sep-18 07:09 AM
@swift-4.2.4
struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swift42 BOT 04-Sep-18 07:09 AM
exit status: 1 with stderr:
<stdin>:7:9: error: expected 'get', 'set', 'willSet', or 'didSet' keyword to start an accessor definition _modify { ^ <stdin>:23:9: error: cannot pass immutable value as inout argument: 'x' is a get-only property mod(&a.x) ^~~~
Avatar
bannzai 04-Sep-18 07:09 AM
https://gist.github.com/omochi/b31f4916fda78e9a2e804c4b2233370d これを試したかったが、ここにもないかんじか (edited)
GitHub Gist: instantly share code, notes, and snippets.
Avatar
omochimetaru 04-Sep-18 07:09 AM
@swift-nightly ←これで
👍 1
Avatar
swiftNightly BOT 04-Sep-18 07:09 AM
exit status: 2 with stderr:
error: unable to invoke subcommand: /usr/bin/swift-←これで (No such file or directory)
😅 1
Avatar
bannzai 04-Sep-18 07:09 AM
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
discord 初心者ガチ勢
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swiftNightly BOT 04-Sep-18 07:10 AM
8
👏 1
Avatar
bannzai 04-Sep-18 07:11 AM
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.x) print(a.y) } main()
Avatar
swiftNightly BOT 04-Sep-18 07:11 AM
1 8
Avatar
norio_nomura 04-Sep-18 07:11 AM
ボットへの投稿は編集することが出来ます。
👍 1
Avatar
bannzai 04-Sep-18 07:12 AM
@swift-nightly
struct Stone { var x: Int { _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.x) print(a.y) } main()
(edited)
Avatar
swiftNightly BOT 04-Sep-18 07:12 AM
exit status: 1 with stderr:
<stdin>:3:9: error: variable with a 'modify' accessor must also have a getter, addressor, or 'read' accessor _modify { ^
Avatar
bannzai 04-Sep-18 07:12 AM
便利
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var xx: Int = 3 yield &xx y = xx } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.x) print(a.y) } main()
Avatar
swiftNightly BOT 04-Sep-18 07:14 AM
1 8
Avatar
bannzai 04-Sep-18 07:16 AM
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var xx: Int = 3 print("before yield \(xx)") yield &xx print("after yield \(xx)") y = xx } } var y: Int = 0 } func mod(_ x: inout Int) { print("before modify") x = 8 print("after modify") } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swiftNightly BOT 04-Sep-18 07:16 AM
before yield 3 before modify after modify after yield 8 8
Avatar
bannzai 04-Sep-18 07:17 AM
なんで、before modify が 2番目なんだ
あ、待てよ
Avatar
omochimetaru 04-Sep-18 07:18 AM
コルーチンがはさまってるのは、modの呼び出し前後です
modの内部での x = 8 は、いままでどおり。
Avatar
bannzai 04-Sep-18 07:19 AM
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var xx: Int = 3 print("before yield \(xx)") yield &xx print("after yield \(xx)") y = xx } } var y: Int = 0 } func mod(_ x: inout Int) { print("before modify") x = 8 print("after modify") } func main() { var a = Stone() print("before coroutine") mod(&a.x) print("after coroutine") print(a.y) } main()
Avatar
swiftNightly BOT 04-Sep-18 07:19 AM
before coroutine before yield 3 before modify after modify after yield 8 after coroutine 8
Avatar
bannzai 04-Sep-18 07:19 AM
おお、なるほど。納得できました。ありがとうございます!
Avatar
omochimetaru 04-Sep-18 07:19 AM
これ、従来は、
modを呼び出す前にテンポラリな変数が作られてmodを呼び出した後
setterを改めて呼び出して処理結果を格納していたんだけど
modifyアクセサだったら、そのようなテンポラリな値を作る事なく、一発で内部に(ポインタで)書き込める (edited)
swift 1
👍 1
Avatar
nekonoki 07-Sep-18 03:15 AM
@swift-4.2.4
class Hoge { func hoge() { let foo = { [weak self] in print(self) guard let self = self else { return } print(self) } foo() } } Hoge().hoge()
(edited)
Avatar
swift42 BOT 07-Sep-18 03:15 AM
Optional(main.Hoge) main.Hoge
stderr:
<stdin>:4:19: warning: expression implicitly coerced from 'Hoge?' to 'Any' print(self) ^~~~ <stdin>:4:19: note: provide a default value to avoid this warning print(self) ^~~~ ?? <#default value#> <stdin>:4:19: note: force-unwrap the value to avoid this warning print(self) ^~~~ ! <stdin>:4:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(self) ^~~~ as Any
(edited)
Avatar
koher 07-Sep-18 03:23 AM
@swift-nightly
let s = #"a\b\c"# print(s)
Avatar
swiftNightly BOT 07-Sep-18 03:24 AM
exit status: 1 with stderr:
<stdin>:1:13: error: invalid escape sequence in literal let s = #"a\b\c"# ^ <stdin>:1:15: error: invalid escape sequence in literal let s = #"a\b\c"# ^ <stdin>:1:9: error: expected initial value after '=' let s = #"a\b\c"# ^ <stdin>:1:8: error: consecutive statements on a line must be separated by ';' let s = #"a\b\c"# ^ ; <stdin>:1:9: error: expected expression let s = #"a\b\c"# ^
Avatar
koher 07-Sep-18 03:24 AM
まだダメだったか。
Avatar
omochimetaru 07-Sep-18 03:24 AM
@swift-nightly --version
Avatar
swiftNightly BOT 07-Sep-18 03:24 AM
Swift version 4.2-dev (LLVM 6d629af647, Clang 257fa19143, Swift 7ad7e1d968) Target: x86_64-unknown-linux-gnu
Avatar
Avatar
koher 07-Sep-18 03:26 AM
まだ出てないね。 https://github.com/apple/swift/releases
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
Avatar
omochimetaru 07-Sep-18 03:27 AM
0904の手前がコケまくってますね。
Avatar
koher 07-Sep-18 03:27 AM
10 日間くらい
Avatar
omochimetaru 07-Sep-18 03:27 AM
SwiftPMのパッケージ分離とかやってたから
ビルド周りをいじっていて壊れてたのかな
Avatar
norio_nomura 07-Sep-18 11:57 PM
@swift-nightly
let s = #"a\b\c"# print(s)
Avatar
swiftNightly BOT 07-Sep-18 11:57 PM
a\b\c
Avatar
koher 08-Sep-18 12:42 AM
おお!
@swift-nightly -swift-version 5
protocol P {} extension P { init(_with instance: Self) { self = instance } } class Animal : P { init() {} convenience init(with instance: Animal) { self.init(_with: instance) } } class Cat : Animal { override init() {} } class Dog : Animal { override init() {} } let cat: Cat = Cat(with: Dog()) // Dog with Cat type??? print(type(of: cat))
(edited)
Avatar
swiftNightly BOT 08-Sep-18 12:43 AM
exit status: 1 with stderr:
<stdin>:10:22: error: cannot convert value of type 'Animal' to expected argument type 'Self' self.init(_with: instance) ^~~~~~~~ as! Self
(edited)
Avatar
koher 08-Sep-18 12:44 AM
こっちはまだか。
Avatar
rintaro 08-Sep-18 12:44 AM
-swift-version 5 でいかがでしょ?
Avatar
koher 08-Sep-18 12:53 AM
おおお
Avatar
koher 08-Sep-18 01:00 AM
この前の @kateinoigakukunself 差し替えのも封じられたかな?最後の付け足しか Q&A かだったのでスライド↓中にコードが見当たらない・・・。 https://speakerdeck.com/kateinoigakukun/konpairakaraniu-jie-kuswift-method-dispatch-1
Avatar
kateinoigakukun 08-Sep-18 01:07 AM
お!これ治るんですね
@swift-nightly -swift-version 5
protocol Animal {} extension Animal { init(_animal: Self) { self = _animal } } class AnimalBase: Animal { convenience init(with animal: AnimalBase) { self.init(_animal: animal) } } class Cat: AnimalBase { let _name = "Tama" var name: String { return _name } func bark() { print(name) } } class Dog: AnimalBase {} let animal = Cat(with: Dog()) animal.bark()
Avatar
swiftNightly BOT 08-Sep-18 01:09 AM
exit status: 1 with stderr:
<stdin>:11:28: error: cannot convert value of type 'AnimalBase' to expected argument type 'Self' self.init(_animal: animal) ^~~~~~ as! Self
Avatar
kateinoigakukun 08-Sep-18 01:10 AM
これは正しい🙌
😀 2
Avatar
hiragram 10-Sep-18 02:32 AM
@swift-4.2.4
struct A { var b: Int = 1 @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 2 } }
これ入力に渡すファイル名って任意に決められるんだっけ
Avatar
kateinoigakukun 10-Sep-18 02:37 AM
-module-name?
Avatar
omochimetaru 10-Sep-18 02:38 AM
ファイル名が変わるわけじゃないけどたしかにモジュール名は指定できるな
Avatar
hiragram 10-Sep-18 02:47 AM
@swift-4.2.4 -module-name hoge
struct A { var b: Int = 1 @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 2 } }
😇
@swift-4.1.3 -module-name hoge
struct A { var b: Int = 1 @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 2 } }
Avatar
swift41 BOT 10-Sep-18 02:48 AM
no output
Avatar
hiragram 10-Sep-18 02:51 AM
@swift-4.1.3
struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 22222 } } print(A().b) print(A().itazura())
Avatar
swift41 BOT 10-Sep-18 02:51 AM
11111 22222
Avatar
hiragram 10-Sep-18 02:51 AM
@swift-4.2.4
struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 22222 } } print(A().b) print(A().itazura())
手元だとどっちも11111なんだけどな
~/D/swift-asobu $ swift --version Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2) Target: x86_64-apple-darwin17.7.0 ~/D/swift-asobu $ swift hoge.swift 11111 11111
Avatar
omochimetaru 10-Sep-18 02:52 AM
手元でも同じマングリングになってる?
マングリングルールはバージョンで結構かわるよ。
Avatar
hiragram 10-Sep-18 02:52 AM
手元で同じマングリングなってる
sil吐かせれば良いのか
@swift-4.1.3 -emit-sil
struct A { var b: Int { return 11111 } }
Avatar
swift41 BOT 10-Sep-18 02:53 AM
exit status: 1 with stderr:
<unknown>:0: error: option '-emit-sil' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
hiragram 10-Sep-18 02:53 AM
だめなんだっけ
swiftcじゃないのか
Avatar
omochimetaru 10-Sep-18 02:54 AM
@swift-4.1.3 -Xfrontend -emit-sil
struct A { var b: Int { return 11111 } }
Avatar
swift41 BOT 10-Sep-18 02:54 AM
sil_stage canonical import Builtin import Swift import SwiftShims struct A { var b: Int { get } init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // A.b.getter sil hidden @_T04main1AV1bSivg : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 11111 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 return %3 : $Int // id: %4 } // end sil function '_T04main1AV1bSivg' // Int.init(_builtinIntegerLiteral:) sil public_external [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int { // %0 // user: %2 bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type): %2 = builtin "s_to_s_checked_trunc_Int2048_Int64"(%0 : $Builtin.Int2048) : $(Builtin.Int64, Builtin.Int1) // user: %3 %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4 %4 = struct $Int (%3 : $Builtin.Int64) // user: %5 return %4 : $Int // id: %5 } // end sil function '_T0S2iBi2048_22_builtinIntegerLiteral_tcfC'
Avatar
hiragram 10-Sep-18 02:55 AM
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge
struct A { var b: Int { return 11111 } }
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge
struct A { var b: Int { return 11111 } }
Avatar
swift41 BOT 10-Sep-18 02:55 AM
sil_stage canonical import Builtin import Swift import SwiftShims struct A { var b: Int { get } init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // A.b.getter sil hidden @_T04hoge1AV1bSivg : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 11111 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 return %3 : $Int // id: %4 } // end sil function '_T04hoge1AV1bSivg' // Int.init(_builtinIntegerLiteral:) sil public_external [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int { // %0 // user: %2 bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type): %2 = builtin "s_to_s_checked_trunc_Int2048_Int64"(%0 : $Builtin.Int2048) : $(Builtin.Int64, Builtin.Int1) // user: %3 %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4 %4 = struct $Int (%3 : $Builtin.Int64) // user: %5 return %4 : $Int // id: %5 } // end sil function '_T0S2iBi2048_22_builtinIntegerLiteral_tcfC'
Avatar
hiragram 10-Sep-18 02:56 AM
手元と一緒だなあ_T04hoge1AV1bSivg
Avatar
omochimetaru 10-Sep-18 02:56 AM
func itazuraつきでやってみたら (edited)
Avatar
hiragram 10-Sep-18 02:57 AM
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge
struct A { var b: Int { return 11111 } func itazura() -> Int { return 22222 } }
Avatar
swift41 BOT 10-Sep-18 02:57 AM
sil_stage canonical import Builtin import Swift import SwiftShims struct A { var b: Int { get } func itazura() -> Int init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // A.b.getter sil hidden @_T04hoge1AV1bSivg : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 11111 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // user: %4 return %3 : $Int // id: %4 } // end sil function '_T04hoge1AV1bSivg' // Int.init(_builtinIntegerLiteral:) sil public_external [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int { // %0 // user: %2 bb0(%0 : $Builtin.Int2048, %1 : $@thin Int.Type): %2 = builtin "s_to_s_checked_trunc_Int2048_Int64"(%0 : $Builtin.Int2048) : $(Builtin.Int64, Builtin.Int1) // user: %3 %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4 %4 = struct $Int (%3 : $Builtin.Int64) // user: %5 return %4 : $Int // id: %5 } // end sil function '_T0S2iBi2048_22_builtinIntegerLiteral_tcfC' // A.itazura() sil hidden @_T04hoge1AV7itazuraSiyF : $@convention(method) (A) -> Int { // %0 // user: %1 bb0(%0 : $A): debug_value %0 : $A, let, name "self", argno 1 // id: %1 %2 = integer_literal $Builtin.Int64, 22222 // user: %3 %3 = struct $Int (%2 : $Bu
Avatar
omochimetaru 10-Sep-18 02:57 AM
_T04hoge1AV7itazuraSiyF
↑おや
ああ、まだあれつけてないのか
Avatar
hiragram 10-Sep-18 02:58 AM
@swift-4.1.3 -Xfrontend -emit-sil -module-name hoge
struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> Int { return 22222 } }
Avatar
swift41 BOT 10-Sep-18 02:58 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/lib/SILGen/SILGen.cpp:638: void swift::Lowering::SILGenModule::preEmitFunction(swift::SILDeclRef, llvm::PointerUnion<ValueDecl *, Expr *>, swift::SILFunction *, swift::SILLocation): Assertion `F->empty() && "already emitted function?!"' failed. #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007f19f566b390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f19f3daa428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f19f3dac02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f19f3da2bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #6 0x00007f19f3da2c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #7 0x0000000000c2be2f swift::Lowering::SILGenModule::preEmitFunction(swift::SILDeclRef, llvm::PointerUnion<swift::ValueDecl*, swift::Expr*>, swift::SILFunction*, swift::SILLocation) (/usr/bin/swift+0xc2be2f) #8 0x0000000000c3336f swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const (/usr/bin/swift+0xc3336f) #9 0x0000000000c2b975 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) (/usr/bin/swift+0xc2b975) #10 0x0000000000ccae75 (anonymous namespace)::SILGenType::emitType() (/usr/bin/swift+0xccae75) #11 0x0000000000ccab98 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) (/usr/bin/swift+0xccab98) #12 0x0000000000c30e6b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) (/usr/bin/swift+0xc30e6b) #13 0x0000000000c31b36 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) (/usr/bin/swift+0xc31b36) #14 0x0000000000c3210d swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&, bool) (/usr/bin/swift+0xc3210d) #15 0x
Avatar
hiragram 10-Sep-18 02:58 AM
チーン
Avatar
omochimetaru 10-Sep-18 02:58 AM
Assertion `F->empty() && "already emitted function?!"' failed.
Avatar
hiragram 10-Sep-18 02:59 AM
Avatar
omochimetaru 10-Sep-18 02:59 AM
アサーションで落ちてるから一応安全に死ねてるね
Avatar
hiragram 10-Sep-18 02:59 AM
おりこう
Avatar
omochimetaru 10-Sep-18 02:59 AM
ま〜アンダースコア付きのアトリビュートだから、自己責任で、おかしくはないか。
Avatar
hiragram 10-Sep-18 02:59 AM
ただ
@swift-4.1.3
struct A { var b: Int { return 11111 } @_silgen_name("_T04hoge1AV1bSivg") func itazura() -> String { return "Hello" } } print(A().itazura())
Avatar
swift41 BOT 10-Sep-18 03:00 AM
Hello
Avatar
hiragram 10-Sep-18 03:00 AM
あれ
手元だとしぬんだがなこれ
4.1.2と4.1.3でいろいろちがうのかな
Avatar
omochimetaru 10-Sep-18 03:03 AM
まあありえそう
言語仕様にない部分は結構頻繁に書き換わってるから
Avatar
hiragram 10-Sep-18 03:05 AM
だんだんコンパイラの気持ちが分かる人の気持ちが分かるようになってきた
Avatar
omochimetaru 10-Sep-18 03:05 AM
例えばそういうときは
さっきのアサーションで落ちる行までのスタックトレースをソースを追いかけてみて
4.1.24.1.3 のタグでチェックアウトしたり、その辺の git blame を見たりする
ブレークポイント貼りながらステップ実行していけばなんか違う挙動をする場所が出てくるだろう
Avatar
hiragram 10-Sep-18 03:06 AM
こういうのってパッチバージョンの違いとMac/Linuxの違いってどっちが違いうるのかな
Avatar
omochimetaru 10-Sep-18 03:06 AM
Mac/LinuxはObjCがあるかどうかで
Avatar
hiragram 10-Sep-18 03:06 AM
C++のところだったら関係ないのかな
そうよね
Avatar
omochimetaru 10-Sep-18 03:06 AM
これはstructだし名前解決とかだから関係なさそう
Avatar
hiragram 10-Sep-18 03:07 AM
ナルホディウス
Avatar
omochimetaru 10-Sep-18 03:07 AM
クラスの場合はデータ構造にも影響あるから
もしかしたら関係があるかもしれん。
ああまあでもそうか、SIL stageだからほぼObjCは関係なさそうだね
Avatar
hiragram 10-Sep-18 03:07 AM
気持ちが分かる人の気持ちが分かるのはまだ遠いな
Avatar
norio_nomura 10-Sep-18 03:54 AM
swift4.2 は@_silgen_name()入れると何故か動かないですね。 (edited)
Avatar
norio_nomura 10-Sep-18 04:02 AM
あいや、swift4.2が全く動いていないのか…
@swift-4.2.4 --version
Avatar
norio_nomura 10-Sep-18 04:28 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a以降、動かなくなってる> @swift-4.2.4
Herokuでロールバックした。> @swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 10-Sep-18 04:31 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a
Avatar
omochimetaru 10-Sep-18 04:40 AM
あ、なるほど、その可能性があったか。
Avatar
norio_nomura 10-Sep-18 04:46 AM
nightlyは動くのに4.2.1-devは動かない。 @swift-nightly
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swiftNightly BOT 10-Sep-18 04:46 AM
DEVELOPMENT-SNAPSHOT-2018-09-08-a
Avatar
tarunon 12-Sep-18 10:10 AM
@swift-4.1.3
import Foundation struct Empty: Codable { } struct Foo: Codable { var empty: Empty } struct Bar: Codable { var empty: [Empty] } struct Piyo<E: Codable>: Codable { var empty: E } let encoder = JSONEncoder() let decoder = JSONDecoder() do { print(try decoder.decode(Bar.self, from: encoder.encode(Foo.init(empty: .init())))) } catch { print(error) } do { print(try decoder.decode(Foo.self, from: encoder.encode(Bar.init(empty: .init())))) } catch { print(error) } do { print(try decoder.decode(Piyo<Empty>.self, from: encoder.encode(Piyo<[Empty]>(empty: .init())))) } catch { print(error) } do { print(try decoder.decode(Piyo<[Empty]>.self, from: encoder.encode(Piyo<Empty>(empty: .init())))) } catch { print(error) }
Avatar
swift41 BOT 12-Sep-18 10:10 AM
⚠️ [DecodingError.typeMismatch: Value of type 'Array<Any>' required for key 'empty'.] Foo(empty: main.Empty()) Piyo<Empty>(empty: main.Empty()) ⚠️ [DecodingError.typeMismatch: Value of type 'Array<Any>' required for key 'empty'.]
Avatar
takka 12-Sep-18 11:04 AM
@swift-4.1.3
import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d", diff.hour!, diff.minute!, diff.second!) )
(edited)
Avatar
swift41 BOT 12-Sep-18 11:04 AM
03:25:45
(edited)
Avatar
takka 12-Sep-18 11:06 AM
@swift-4.1.3
import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d.%d", diff.hour!, diff.minute!, diff.second!, diff.nanosecond!) )
Avatar
swift41 BOT 12-Sep-18 11:06 AM
03:25:45.0
Avatar
takka 12-Sep-18 11:10 AM
@swift-4.1.3
import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d.%d", diff.hour!, diff.minute!, diff.second!, diff.nanosecond!) )
Avatar
swift41 BOT 12-Sep-18 11:10 AM
exit status: 4 with stderr:
Fatal error: file Foundation/NSCalendar.swift, line 617 #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007fe2f1ecd390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007fe2ecd880b9 _T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstFTf4nxnnn_n (/usr/lib/swift/linux/libswiftCore.so+0x2bb0b9) #4 0x00007fe2ecc1a41c _T0s17_assertionFailures5NeverOs12StaticStringV_SSAE4fileSu4lines6UInt32V5flagstF (/usr/lib/swift/linux/libswiftCore.so+0x14d41c) #5 0x00007fe2e9417056 _T010Foundation10NSCalendarC10componentsAA14DateComponentsVAC4UnitV_AA0D0V4fromAJ2toAC7OptionsV7optionstF (/usr/lib/swift/linux/libFoundation.so+0x3b0056) #6 0x00007fe2e97bac21 _T010Foundation8CalendarV14dateComponentsAA04DateD0Vs3SetVyAC9ComponentOG_AA0E0V4fromAM2totFAfA10NSCalendarCcfU_TA (/usr/lib/swift/linux/libFoundation.so+0x753c21) #7 0x00007fe2e97baa64 _T010Foundation10NSCalendarCAA14DateComponentsVs5Error_pIgxozo_AcEsAF_pIgxrzo_TRTA (/usr/lib/swift/linux/libFoundation.so+0x753a64) #8 0x00007fe2e97c0889 _T010Foundation10NSCalendarCAA14DateComponentsVs5Error_pIgxozo_AcEsAF_pIgxrzo_TRTA.124 (/usr/lib/swift/linux/libFoundation.so+0x759889) #9 0x00007fe2e96f7e29 _T010Foundation14_MutableHandleC3mapqd__qd__xKcKlF (/usr/lib/swift/linux/libFoundation.so+0x690e29) #10 0x00007fe2e97b3e7a _T010Foundation8CalendarV14dateComponentsAA04DateD0Vs3SetVyAC9ComponentOG_AA0E0V4fromAM2totF (/usr/lib/swift/linux/libFoundation.so+0x74ce7a) #11 0x00007fe2f22fd16c #12 0x0000000000fed3be llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0xfed3be) #13 0x0000000000ff1882 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, st
Avatar
norio_nomura 12-Sep-18 12:42 PM
@swift-4.1.3 demangle _T010Foundation10NSCalendarC10componentsAA14DateComponentsVAC4UnitV_AA0D0V4fromAJ2toAC7OptionsV7optionstF
Avatar
swift41 BOT 12-Sep-18 12:42 PM
_T010Foundation10NSCalendarC10componentsAA14DateComponentsVAC4UnitV_AA0D0V4fromAJ2toAC7OptionsV7optionstF ---> Foundation.NSCalendar.components(Foundation.NSCalendar.Unit, from: Foundation.Date, to: Foundation.Date, options: Foundation.NSCalendar.Options) -> Foundation.DateComponents
Avatar
norio_nomura 12-Sep-18 12:44 PM
LinuxでDate関連のnanosecond周りはバグだらけ。
Avatar
koher 12-Sep-18 02:20 PM
@swift-nightly -swift-version 5
enum Result<Value, Error: Swift.Error> { case success(Value) case failure(Error) func get() throws -> Value { switch self { case .success(let value): return value case .failure(let error): throw error } } } extension Result where Error == Never { func get() -> Value { switch self { case .success(let value): return value } } } let a: Result<Int, Never> = .success(42) print(a.get())
Avatar
swiftNightly BOT 12-Sep-18 02:21 PM
42
Avatar
norio_nomura 13-Sep-18 01:36 PM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a以降でボットが動かない症状、URLSession.dataTask(with:)へ渡したURLRequesthttpBodyURLSessionDataTask内部で失われているらしいところまでは把握したのだけれど、最低限の再現条件がわからなくてbugs.swift.orgへ登録できない…
Avatar
kateinoigakukun 15-Sep-18 06:26 AM
@swift-4.2.4
protocol P1 { associatedtype A1 associatedtype A2 } protocol P2: P1 where A2 == A3 { typealias A3 = A1 } class S: P2 { typealias A1 = Int typealias A2 = A3 }
(edited)
ありゃ
@swift-nightly
protocol P1 { associatedtype A1 associatedtype A2 } protocol P2: P1 where A2 == A3 { typealias A3 = A1 } class S: P2 { typealias A1 = Int typealias A2 = A3 }
Avatar
swiftNightly BOT 15-Sep-18 06:27 AM
exit status: 1 with stderr:
<stdin>:10:7: error: type 'S' does not conform to protocol 'P1' class S: P2 { ^ <stdin>:3:20: note: protocol requires nested type 'A2'; do you want to add it? associatedtype A2 ^ <stdin>:10:7: error: type 'S' does not conform to protocol 'P2' class S: P2 { ^
Avatar
norio_nomura 15-Sep-18 07:22 AM
おっと、動かないバージョンへアップデートされたままでした。動くバージョンへロールバックしました。> @swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
🙌 1
Avatar
swift42 BOT 15-Sep-18 07:22 AM
4.2-DEVELOPMENT-SNAPSHOT-2018-08-25-a
Avatar
norio_nomura 15-Sep-18 10:20 AM
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-07-a以降でボットが動かない症状、URLSession.dataTask(with:)へ渡したURLRequestのhttpBodyがURLSessionDataTask内部で失われているらしいところまでは把握したのだけれど、最低限の再現条件がわからなくてbugs.swift.orgへ登録できない…
再現できた。 https://bugs.swift.org/browse/SR-8759
クッキーを受け取ったドメインに対してURLRequesthttpBodyが送られなくなるらしい。
Avatar
norio_nomura 15-Sep-18 12:18 PM
swift-corelibs-foundationの不具合を回避して更新しました。> @swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 15-Sep-18 12:18 PM
4.2-DEVELOPMENT-SNAPSHOT-2018-09-14-a
Avatar
norio_nomura 17-Sep-18 10:08 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 17-Sep-18 10:08 AM
4.2-RELEASE
Avatar
kateinoigakukun 18-Sep-18 02:24 AM
@swift-4.2.4 @swift-4.1.3
protocol P {} protocol Foo {} extension Int: P {} extension Array: Foo where Element: P {} let a = [1,2,3] print(a is Foo)
(edited)
Avatar
swift42 BOT 18-Sep-18 02:24 AM
true
stderr:
<stdin>:8:9: warning: 'is' test is always true print(a is Foo) ^
(edited)
Avatar
swift41 BOT 18-Sep-18 02:24 AM
exit status: 134 with stderr:
<stdin>:8:9: warning: 'is' test is always true print(a is Foo) ^ warning: Swift runtime does not yet support dynamically querying conditional conformance ('Swift.Array<Swift.Int>': 'main.Foo') Could not cast value of type 'Swift.Array<Swift.Int>' (0x7f1e0cfb7240) to 'main.Foo' (0x7f1e0cfb7280). #0 0x0000000003f25074 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f25074) #1 0x0000000003f253b6 SignalHandler(int) (/usr/bin/swift+0x3f253b6) #2 0x00007f1e11cc7390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #3 0x00007f1e10406428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #4 0x00007f1e1040802a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #5 0x00007f1e0ce92fd3 (/usr/lib/swift/linux/libswiftCore.so+0x39dfd3) #6 0x00007f1e0ce8f599 (/usr/lib/swift/linux/libswiftCore.so+0x39a599) #7 0x00007f1e0ce8f5eb (/usr/lib/swift/linux/libswiftCore.so+0x39a5eb) #8 0x00007f1e0ce90b38 _dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags) (/usr/lib/swift/linux/libswiftCore.so+0x39bb38) #9 0x00007f1e120f624d #10 0x00007f1e120f610e #11 0x0000000000fed3be llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/usr/bin/swift+0xfed3be) #12 0x0000000000ff1882 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/usr/bin/swift+0xff1882) #13 0x00000000004d9076 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift:
Avatar
taketo1024 18-Sep-18 07:33 AM
https://github.com/taketo1024/SwiftyMath SwiftyMath を Swift4.2 対応しました 👏 w @Kishikawa Katsumi SwiftBot に組み込んで頂いてたと思うので、よかったら(とても暇なときにでも)アップデートして下さい 🙏
Pure Math in Pure Swift. Contribute to taketo1024/SwiftyMath development by creating an account on GitHub.
🙌 1
Avatar
Kishikawa Katsumi 18-Sep-18 07:38 AM
👍
Avatar
koher 18-Sep-18 07:40 AM
Pure Math in Pure Swift.
かっこいい・・・
😉 1
Avatar
Kishikawa Katsumi 18-Sep-18 07:41 AM
@taketo1024 そういえば、SwiftyMathはBotだけですけど、BotのバックエンドはWebなので、Webで使えるようにすることもたぶん難しくないのですが、 https://swift-playground.kishikawakatsumi.com/ ^ Webでできたら何かおもしろい利用方法があるとかあります?
Avatar
taketo1024 18-Sep-18 07:42 AM
おぉ!面白いというよりはとても助かる利用方法として、これを使ってもらいたい人たちが必ずしも Mac ユーザでないので、Web で利用可能になると大変ありがたいです!
Avatar
Kishikawa Katsumi 18-Sep-18 07:43 AM
たぶんそんな気がしてたんですよね。
Avatar
taketo1024 18-Sep-18 07:46 AM
😂
Avatar
taketo1024 18-Sep-18 08:01 AM
コードはこちらですかね 🙂 あんまり重い処理を回されては困るというようなことがあれば、自分でホスティングします 🙇 https://github.com/kishikawakatsumi/swift-playground
Contribute to kishikawakatsumi/swift-playground development by creating an account on GitHub.
Avatar
Kishikawa Katsumi 18-Sep-18 08:03 AM
まあ、タイムアウトもあるんでそんなに心配はしてないですけどね。コードはそれです。 Dockerとかが想定通りになってればそのまま動きます。
Avatar
taketo1024 18-Sep-18 08:03 AM
了解です!
Avatar
Kishikawa Katsumi 18-Sep-18 08:28 AM
@taketo1024 私のPlaygroundは必要最低限ですけど、うまいことコードとか説明とかUIを作ったら、楽しくインタラクティブに数学を学べる環境になると思うので、もしそういうことをやる場合は手伝うので教えてください。
Avatar
taketo1024 18-Sep-18 08:29 AM
ありがとうございます、めっちゃ嬉しいです😍
Avatar
norio_nomura 21-Sep-18 12:15 AM
swift-nightlyボットがビルド出来なくなった修正のついでに、SwiftyMathを使える様にしてみました。 @swift-4.2.4 @swift-nightly
import SwiftyMath let a = 𝐐(4, 5) // 4/5 let b = 𝐐(3, 2) // 3/2 print(a + b) // 23/10
Avatar
swift42 BOT 21-Sep-18 12:15 AM
23/10
Avatar
swiftNightly BOT 21-Sep-18 12:15 AM
23/10
Avatar
rintaro 21-Sep-18 08:39 AM
@swift-4.2.4
Int(Double(Int.max))
Avatar
swift42 BOT 21-Sep-18 08:39 AM
exit status: 4 with stderr:
<stdin>:1:1: warning: result of 'Int' initializer is unused Int(Double(Int.max)) ^ ~~~~~~~~~~~~~~~~~ Fatal error: Double value cannot be converted to Int because the result would be greater than Int.max Current stack trace: 0 libswiftCore.so 0x00007f5ca0e9ff30 _swift_stdlib_reportFatalError + 168 1 libswiftCore.so 0x00007f5ca0bf7c6a <unavailable> + 1502314 2 libswiftCore.so 0x00007f5ca0e3515e <unavailable> + 3850590 3 libswiftCore.so 0x00007f5ca0bf7c6a <unavailable> + 1502314 4 libswiftCore.so 0x00007f5ca0d90059 <unavailable> + 3174489 5 libswiftCore.so 0x00007f5ca0bf7730 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000001042d2e <unavailable> + 12856622 8 swift 0x0000000001046e52 <unavailable> + 12873298 9 swift 0x00000000004f8b52 <unavailable> + 1018706 10 swift 0x00000000004df0cb <unavailable> + 913611 11 swift 0x00000000004da400 <unavailable> + 893952 12 swift 0x000000000048a348 <unavailable> + 566088 13 libc.so.6 0x00007f5ca3833740 __libc_start_main + 240 14 swift 0x0000000000488009 <unavailable> + 557065 #0 0x0000000004108b64 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x4108b64) #1 0x00000000041069f2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x41069f2) #2 0x0000000004108d12 SignalHandler(int) (/usr/bin/swift+0x4108d12) #3 0x00007f5ca5109390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f5ca0d90061 $Ss18_fatalErrorMessage__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtFTf4nnddn_n (/usr/lib/swift/linux/libswiftCore.so+0x307061) #5 0x00007f5ca0bf7743 $Ss18_fatalErrorMessage__4file4line5flagss5Ne
Avatar
rintaro 21-Sep-18 08:39 AM
これはしょうがないのか?
Avatar
omochimetaru 21-Sep-18 08:41 AM
Double value cannot be converted to Int because the result would be greater than Int.max
Avatar
rintaro 21-Sep-18 08:41 AM
Double のビット数考えればしょうがないか。
Avatar
omochimetaru 21-Sep-18 08:41 AM
@swift-4.2.4
Int(Float(Int.max) * 2)
Avatar
swift42 BOT 21-Sep-18 08:41 AM
exit status: 4 with stderr:
<stdin>:1:1: warning: result of 'Int' initializer is unused Int(Float(Int.max) * 2) ^ ~~~~~~~~~~~~~~~~~~~~ Fatal error: Float value cannot be converted to Int because the result would be greater than Int.max Current stack trace: 0 libswiftCore.so 0x00007fe934031f30 _swift_stdlib_reportFatalError + 168 1 libswiftCore.so 0x00007fe933d89c6a <unavailable> + 1502314 2 libswiftCore.so 0x00007fe933fc715e <unavailable> + 3850590 3 libswiftCore.so 0x00007fe933d89c6a <unavailable> + 1502314 4 libswiftCore.so 0x00007fe933f22059 <unavailable> + 3174489 5 libswiftCore.so 0x00007fe933d89730 _fatalErrorMessage(_:_:file:line:flags:) + 19 7 swift 0x0000000001042d2e <unavailable> + 12856622 8 swift 0x0000000001046e52 <unavailable> + 12873298 9 swift 0x00000000004f8b52 <unavailable> + 1018706 10 swift 0x00000000004df0cb <unavailable> + 913611 11 swift 0x00000000004da400 <unavailable> + 893952 12 swift 0x000000000048a348 <unavailable> + 566088 13 libc.so.6 0x00007fe9369c5740 __libc_start_main + 240 14 swift 0x0000000000488009 <unavailable> + 557065 #0 0x0000000004108b64 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x4108b64) #1 0x00000000041069f2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x41069f2) #2 0x0000000004108d12 SignalHandler(int) (/usr/bin/swift+0x4108d12) #3 0x00007fe93829b390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007fe933f22061 $Ss18_fatalErrorMessage__4file4line5flagss5NeverOs12StaticStringV_A2HSus6UInt32VtFTf4nnddn_n (/usr/lib/swift/linux/libswiftCore.so+0x307061) #5 0x00007fe933d89743 $Ss18_fatalErrorMessage__4file4line5flag
Avatar
omochimetaru 21-Sep-18 08:41 AM
なるほど
Avatar
rintaro 21-Sep-18 08:42 AM
@swift-4.2.4
print(Int(Float80(Int.max)))
(edited)
Avatar
swift42 BOT 21-Sep-18 08:42 AM
9223372036854775807
(edited)
👏 1
Avatar
koher 21-Sep-18 08:45 AM
一方で・・・ @swift-4.2.4
print(Int(Double(Int.min)))
(edited)
Avatar
swift42 BOT 21-Sep-18 08:45 AM
-9223372036854775808
(edited)
Avatar
koher 21-Sep-18 08:46 AM
丸め方向によるランダム的挙動。
Avatar
omochimetaru 21-Sep-18 08:46 AM
あれ?
Doubleで精度不足になったときに
@swift-4.2.4
print(Int.min) print(Int(Double(Int.min)))
Avatar
swift42 BOT 21-Sep-18 08:47 AM
-9223372036854775808 -9223372036854775808
Avatar
omochimetaru 21-Sep-18 08:48 AM
あ〜
@swift-4.2.4
import Foundation print(String(format: "%x", Int.min))
(edited)
Avatar
swift42 BOT 21-Sep-18 08:49 AM
0
(edited)
Avatar
omochimetaru 21-Sep-18 08:49 AM
Avatar
koher 21-Sep-18 08:50 AM
↓これはどうなってんだ??
// Kotlin fun main(args: Array<String>) { println(Long.MAX_VALUE) println(Long.MAX_VALUE.toDouble().toLong()) }
9223372036854775807 9223372036854775807
(edited)
Avatar
omochimetaru 21-Sep-18 08:50 AM
@swift-4.2.4
import Foundation print(String(format: "%lx", Int.min))
Avatar
swift42 BOT 21-Sep-18 08:50 AM
8000000000000000
Avatar
omochimetaru 21-Sep-18 08:51 AM
負の最大数は 0b10000.... ってパターンだから、
いや、ちがうか、仮数部に入るのは絶対値か
@swift-4.2.4
import Foundation let x: Int128 = abs(Int128(Int.min)) print(String(format: "%llx", x))
Avatar
swift42 BOT 21-Sep-18 08:52 AM
exit status: 1 with stderr:
<stdin>:2:8: error: use of undeclared type 'Int128' let x: Int128 = abs(Int128(Int.min)) ^~~~~~
Avatar
omochimetaru 21-Sep-18 08:52 AM
Avatar
koher 21-Sep-18 08:55 AM
Kotlin のは、単に max 超えてるのは全部 max に丸められるだけだった。
LongInt とかと同じで上位ビット切り捨てかと思ってた。 (edited)
Avatar
norio_nomura 21-Sep-18 09:12 AM
Double のビット数考えればしょうがないか。
変換できないのが?クラッシュするのが?
Avatar
rintaro 21-Sep-18 09:15 AM
ビット数により精度を保てないが故にオーバーフローしてクラッシュするのが、ですね。
Avatar
koher 21-Sep-18 09:17 AM
Int.min だとクラッシュしないのが微妙ですね。丸め方向の偶然に挙動が委ねられてる感が。
Avatar
norio_nomura 21-Sep-18 09:19 AM
@swift-4.2.4 -frontend -repl
Int(exactly: Double(Int.max))
(edited)
Avatar
swift42 BOT 21-Sep-18 09:19 AM
// r0 : Int? = nil
(edited)
Avatar
omochimetaru 21-Sep-18 09:42 AM
exactlyだと、だめなときはnilか。
Avatar
kateinoigakukun 22-Sep-18 12:00 PM
@swift-4.2.4
protocol P { func foo() -> Int } struct S: P { @_implements(P, foo()) func bar() -> Int { return 1 } }
Avatar
swift42 BOT 22-Sep-18 12:00 PM
no output
Avatar
kateinoigakukun 22-Sep-18 12:00 PM
@_implements初めて知った
👀 1
Avatar
tarunon 22-Sep-18 01:06 PM
悪いことできそう
😈 1
Avatar
kateinoigakukun 22-Sep-18 01:38 PM
@swift-4.2.4 @swift-nightly
struct X {} protocol P1 { associatedtype U } protocol P2: P1 {} extension P2 { @_implements(P1, U) typealias _Default_U = X } struct S<A>: P2 {} extension S where A: P1 { typealias U = A.U }
(edited)
Avatar
swift42 BOT 22-Sep-18 01:38 PM
exit status: 134 with stderr:
error type should not appear in IRGen UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/IRGen/MetadataRequest.cpp:1258! #0 0x000000000410afb4 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410afb4) #1 0x0000000004108e42 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108e42) #2 0x000000000410b162 SignalHandler(int) (/usr/bin/swift+0x410b162) #3 0x00007f943313c390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f943187b428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f943187d02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00000000040a3f4d llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) (/usr/bin/swift+0x40a3f4d) #7 0x0000000000631e17 swift::CanTypeVisitor<(anonymous namespace)::EmitTypeMetadataRef, swift::irgen::MetadataResponse, swift::irgen::DynamicMetadataRequest>::visit(swift::CanType, swift::irgen::DynamicMetadataRequest) (/usr/bin/swift+0x631e17) #8 0x0000000000634708 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>::callback_fn<swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_2>(long, swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*) (/usr/bin/swift+0x634708) #9 0x0000000000634566 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::Explosion&)>::callback_fn<swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>)::$_1>(long, swift::irgen::IRGenFunction&, swift::irgen::Explosion&) (/usr/bin/swift+0x634566) #10 0
(edited)
Avatar
swiftNightly BOT 22-Sep-18 01:39 PM
exit status: 134 with stderr:
error type should not appear in IRGen UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/IRGen/MetadataRequest.cpp:1230! Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio-ssl-93eb7dfa/Sources/CNIOOpenSSL/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/libbcrypt/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOLinux/include -I /Libraries/.build/checkouts/SwiftBacktrace-fcbf89ea/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace-fcbf89ea/Sources/Clibunwind/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOOpenSSL.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-ssl-support-a3e27b6f/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/crypto-36ec1aea/Sources/libbcrypt/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown
Avatar
takasek 26-Sep-18 05:00 PM
@swift-4.2.4
var iterator = [1].enumerated().makeIterator() _ = iterator.next()
Avatar
swift42 BOT 26-Sep-18 05:00 PM
no output
Avatar
omochimetaru 27-Sep-18 01:42 AM
@swift-4.2.4
var a = AnyCollection([1,2,3]) let idxs = a.indices print(idxs)
Avatar
swift42 BOT 27-Sep-18 01:42 AM
DefaultIndices<AnyCollection<Int>>(_elements: Swift.AnyCollection<Swift.Int>(_box: Swift._RandomAccessCollectionBox<Swift.Array<Swift.Int>>), _startIndex: (), _endIndex: ())
stderr:
warning: the Swift runtime was unable to demangle the type of field '_startIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors warning: the Swift runtime was unable to demangle the type of field '_endIndex'. the mangled type name is '5IndexSlQz'. this field will show up as an empty tuple in Mirrors
Avatar
rintaro 27-Sep-18 08:32 AM
@swift-4.2.4 @swift-nightly
protocol P {} extension P { typealias Concrete = S } struct S : P {} let a: P = .Concrete.self print(a)
Avatar
swift42 BOT 27-Sep-18 08:32 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/llvm/include/llvm/Support/Casting.h:255: typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = swift::MetatypeType, Y = swift::TypeBase]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed. #0 0x000000000410b054 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410b054) #1 0x0000000004108ee2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108ee2) #2 0x000000000410b202 SignalHandler(int) (/usr/bin/swift+0x410b202) #3 0x00007f045adde390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f045951d428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f045951f02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007f0459515bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #7 0x00007f0459515c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #8 0x0000000000c7225a swift::Lowering::SILGenBuilder::createMetatype(swift::SILLocation, swift::SILType) (/usr/bin/swift+0xc7225a) #9 0x0000000000cafec9 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) (/usr/bin/swift+0xcafec9) #10 0x0000000000ca2c28 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) (/usr/bin/swift+0xca2c28) #11 0x0000000000cbdfdf swift::Lowering::ManagedValue llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SGFContext)>::callback_fn<(anonymous namespace)::RValueEmitter::visitErasureExpr(swift::ErasureExpr*, swift::Lowering::SGFContext)::$_8>(long, swift::Lowering::SGFContext) (/usr/bin/swift+0xcbdfdf) #12 0x0000000000c8a59a std::_Function_handler<void (swift::SILValue), swift::Lowering::SILGenFunction::emitExistentialErasure(swift::SILLocation, swift::CanType, swift::Lowering::TypeLowering const&, swift::Lowering::TypeLowering const&,
Avatar
swiftNightly BOT 27-Sep-18 08:32 AM
exit status: 1 with stderr:
<stdin>:7:13: error: type of expression is ambiguous without more context let a: P = .Concrete.self ~^~~~~~~~
Avatar
rintaro 27-Sep-18 08:33 AM
@swift-4.2.4 @swift-nightly
protocol P {} extension P { typealias Concrete = S } struct S : P {} let a: P = .Concrete() print(a)
Avatar
swift42 BOT 27-Sep-18 08:33 AM
exit status: 1 with stderr:
<stdin>:7:13: error: member 'Concrete' is not a function let a: P = .Concrete() ^ ~~
Avatar
swiftNightly BOT 27-Sep-18 08:33 AM
S()
Avatar
rintaro 27-Sep-18 08:34 AM
↑なんかすごい変なバグ発見したと思ったけどなんとなく直ってた。
Avatar
omochimetaru 27-Sep-18 08:35 AM
その謎のドット何・・・
Avatar
t.ae 27-Sep-18 08:36 AM
左辺の型のstaticメソッドとかは省略できるやつでは
Avatar
omochimetaru 27-Sep-18 08:36 AM
なるほど。
Avatar
rintaro 27-Sep-18 08:46 AM
ちなみに最初のほうのやつは、Xcode10 の Swift4.2 だとコンパイルも実行も通ってしまいます。
Avatar
masakihori 28-Sep-18 08:06 AM
@swift-4.2.4
protocol Hoge { associatedtype Fuga func piyo(_ index: Int) -> Fuga } extension Array: Hoge where Element == String { typealias Fuga = String func piyo(_ index: Int) -> Fuga { return self[index] } } extension Array: Hoge where Element == Int { typealias Fuga = Int func piyo(_ index: Int) -> Fuga { return self[index] } }
(edited)
Avatar
swift42 BOT 28-Sep-18 08:06 AM
exit status: 1 with stderr:
<stdin>:15:13: error: invalid redeclaration of 'Fuga' typealias Fuga = Int ^ <stdin>:8:13: note: 'Fuga' previously declared here typealias Fuga = String ^ <stdin>:9:30: error: 'Fuga' is ambiguous for type lookup in this context func piyo(_ index: Int) -> Fuga { ^~~~ <stdin>:8:13: note: found this candidate typealias Fuga = String ^ <stdin>:15:13: note: found this candidate typealias Fuga = Int ^ <stdin>:16:30: error: 'Fuga' is ambiguous for type lookup in this context func piyo(_ index: Int) -> Fuga { ^~~~ <stdin>:8:13: note: found this candidate typealias Fuga = String ^ <stdin>:15:13: note: found this candidate typealias Fuga = Int ^ <stdin>:7:1: error: type 'Array<Element>' does not conform to protocol 'Hoge' extension Array: Hoge where Element == String { ^ <stdin>:2:18: note: multiple matching types named 'Fuga' associatedtype Fuga ^ <stdin>:8:13: note: possibly intended match typealias Fuga = String ^ <stdin>:15:13: note: possibly intended match typealias Fuga = Int ^ <stdin>:14:18: error: conflicting conformance of 'Array<Element>' to protocol 'Hoge'; there cannot be more than one conformance, even with different conditional bounds extension Array: Hoge where Element == Int { ^ <stdin>:7:1: note: 'Array<Element>' declares conformance to protocol 'Hoge' here extension Array: Hoge where Element == String { ^
(edited)
Avatar
masakihori 28-Sep-18 08:07 AM
なるほど
@swift-4.2.4
protocol Hoge { associatedtype Fuga func piyo(_ index: Int) -> Fuga } extension Array: Hoge where Element == String { typealias Fuga = String func piyo(_ index: Int) -> String { return self[index] + "でーす" } } extension Array: Hoge where Element == Int { typealias Fuga = Int func piyo(_ index: Int) -> Int { return self[index] + 10 } }
Avatar
swift42 BOT 28-Sep-18 08:10 AM
exit status: 1 with stderr:
<stdin>:15:13: error: invalid redeclaration of 'Fuga' typealias Fuga = Int ^ <stdin>:8:13: note: 'Fuga' previously declared here typealias Fuga = String ^ <stdin>:7:1: error: type 'Array<Element>' does not conform to protocol 'Hoge' extension Array: Hoge where Element == String { ^ <stdin>:2:18: note: multiple matching types named 'Fuga' associatedtype Fuga ^ <stdin>:8:13: note: possibly intended match typealias Fuga = String ^ <stdin>:15:13: note: possibly intended match typealias Fuga = Int ^ <stdin>:14:18: error: conflicting conformance of 'Array<Element>' to protocol 'Hoge'; there cannot be more than one conformance, even with different conditional bounds extension Array: Hoge where Element == Int { ^ <stdin>:7:1: note: 'Array<Element>' declares conformance to protocol 'Hoge' here extension Array: Hoge where Element == String { ^
Avatar
norio_nomura 02-Oct-18 02:38 PM
@swift-nightly -frontend -repl
class Animal {} class Cat<T>: Animal {} func foo(_: Animal) { print("Animal") } func foo<T>(_: Cat<T>) { print("Cat") } let cat = Cat<Int>() :constraints debug on foo(cat)
Avatar
swiftNightly BOT 02-Oct-18 02:38 PM
exit status: 11 with stderr:
Stack dump: 0. Program arguments: swift -frontend -I /Libraries/.build/x86_64-unknown-linux/debug -L /Libraries/.build/x86_64-unknown-linux/debug -lLibraries -DDEBUG -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOZlib/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOOpenSSL.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-ssl-93eb7dfa/Sources/CNIOOpenSSL/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CCryptoOpenSSL.build/module.modulemap -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CCryptoOpenSSL/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBcrypt/include/module.modulemap -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBcrypt/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBase32/include/module.modulemap -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBase32/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-ssl-support-a3e27b6f/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinu
Avatar
norio_nomura 02-Oct-18 02:39 PM
むう、nightlyがLLVMSymbolizerでエラーになるな。
1. while processing REPL source: class Animal {} LLVMSymbolizer: error reading file: No such file or directory. LLVMSymbolizer: error reading file: No such file or directory. LLVMSymbolizer: error reading file: No such file or directory. #0 0x000000000459a4b4 (swift+0x459a4b4) #1 0x0000000004598280 (swift+0x4598280) #2 0x000000000459a662 (swift+0x459a662) #3 0x00007f494a31e390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f494a74e000
Avatar
norio_nomura 03-Oct-18 03:15 PM
@swift-4.2.4 -frontend -repl
class Animal {} class Cat<T>: Animal {} func foo(_: Animal) { print("Animal") } func foo<T>(_: Cat<T>) { print("Cat") } let cat = Cat<Int>() :constraints debug on foo(cat)
(edited)
Avatar
swift42 BOT 03-Oct-18 03:15 PM
// cat : Cat<Int> = REPL.Cat<Swift.Int> Animal
stderr:
---Constraint solving for the expression at [<REPL Input>:1:1 - line:1:8]--- (overload set choice binding $T1 := Cat<Int>) ---Initial constraints for the given expression--- (call_expr type='()' location=<REPL Input>:1:1 range=[<REPL Input>:1:1 - line:1:8] arg_labels=_: (overloaded_decl_ref_expr type='$T0' location=<REPL Input>:1:1 range=[<REPL Input>:1:1 - line:1:1] name=foo number_of_decls=2 function_ref=single decls=[ REPL.(file).foo@<REPL Input>:1:6, REPL.(file).foo@<REPL Input>:1:6]) (paren_expr type='(Cat<Int>)' location=<REPL Input>:1:5 range=[<REPL Input>:1:4 - line:1:8] (declref_expr type='Cat<Int>' location=<REPL Input>:1:5 range=[<REPL Input>:1:5 - line:1:5] decl=REPL.(file).cat@<REPL Input>:1:5 direct_to_storage function_ref=unapplied))) Score: 0 0 0 0 0 0 0 0 0 0 0 Type Variables: $T0 [lvalue allowed] subtype_of_existential involves_type_vars bindings={} @ locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1] $T1 [lvalue allowed] as Cat<Int> @ locator@0x81d2f60 [DeclRef@<REPL Input>:1:5] Active Constraints: Inactive Constraints: disjunction [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]:$T0 bound to decl REPL.(file).foo@<REPL Input>:1:6 : (Animal) -> () at <REPL Input>:1:6 [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]; or $T0 bound to decl REPL.(file).foo@<REPL Input>:1:6 : <T> (Cat<T>) -> () at <REPL Input>:1:6 [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]; (Cat<Int>) -> () applicable fn $T0 [[locator@0x81d2fe0 [Call@<REPL Input>:1:1 -> apply function]]]; Resolved overloads: selected overload set choice cat: $T1 == Cat<Int> (assuming $T0 bound to decl REPL.(file).foo@<REPL Input>:1:6 : (Animal) -> () at <REPL Input>:1:6 [[locator@0x81d2e10 [OverloadedDeclRef@<REPL Input>:1:1]]]; (overload set choice binding $T0 := (Animal) -> ()) (found solution 0 0 0 0 0 0 0 0 0 0 0) ) (assuming $T0 bound to decl REPL.(file).
(edited)
Avatar
norio_nomura 03-Oct-18 03:15 PM
Discordのメッセージサイズに収まらない出力のアップロード先を https://file.io から https://ptpb.pw へ変更しました。 (edited)
file.ioは一度urlへアクセスすると削除されてしまうサービスでしたが、ptpb.pwでは削除されません。
https://ptpb.pw/8gvL.txt/text#L-17 の様に各行へのリンクも貼れるので、共有しやすくなったかも? (edited)
👍 4
Avatar
omochimetaru 06-Oct-18 07:17 PM
@swift-4.2.4
var f: (() -> Void)? class Cat { deinit { f?() } } func main() { let cat = Cat() f = { [weak cat] in print(cat == nil) // true } } main()
(edited)
Avatar
swift42 BOT 06-Oct-18 07:17 PM
exit status: 2 with stderr:
error: unable to invoke subcommand: /usr/bin/swift-
swift (No such file or directory) ```
Avatar
omochimetaru 06-Oct-18 07:18 PM
@swift-4.2.4
var f: (() -> Void)? class Cat { deinit { f?() } } func main() { let cat = Cat() f = { [weak cat] in print(cat == nil) // true } } main()
Avatar
swift42 BOT 06-Oct-18 07:18 PM
true
Avatar
omochimetaru 06-Oct-18 07:18 PM
deinit中のオブジェクトはweakから見るとnil
Avatar
rintaro 09-Oct-18 08:31 AM
@swiftbot
class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let str: String.Type = B.Aliased.self let dbl: Double.Type = B.Aliased.self print(str) print(dbl)
🛠 1
Avatar
swiftbot BOT 09-Oct-18 08:31 AM
Author icon rintaro
class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let str: String.Type = B.Aliased.self let dbl: Double.Type = B.Aliased.self print(str) print(dbl)
Version:
swift-4.1.1-RELEASE
Output:
String Double
Error:
Avatar
omochimetaru 09-Oct-18 08:31 AM
??
どう理解すればいいんだ・・・
Avatar
rintaro 09-Oct-18 08:32 AM
オーバーロードといっていいのか・・・
Avatar
omochimetaru 09-Oct-18 08:32 AM
B.Aliased と A.Aliased が B.Aliased という式でオーバーロード?されてる?
そもそもA.AliasedをBで変更するのだと思っていました
Avatar
rintaro 09-Oct-18 08:34 AM
B.Aliased を型推論させると当然のように Double に解決されるんですけどね。
Avatar
omochimetaru 09-Oct-18 08:35 AM
@swiftbot
class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let a: A.Type = B.self print(a.Aliased.self)
🛠 1
Avatar
swiftbot BOT 09-Oct-18 08:35 AM
Author icon omochimetaru
class A { typealias Aliased = String } class B : A { typealias Aliased = Double } let a: A.Type = B.self print(a.Aliased.self)
Version:
swift-4.1.1-RELEASE
Output:
String
Error:
Avatar
omochimetaru 09-Oct-18 08:35 AM
静的に別スコープなのか〜
Avatar
t.ae 09-Oct-18 08:39 AM
assoctype付けるとA.Aliasedが見えなくなるあたりfuncのオーバーロードと似てる?
Avatar
omochimetaru 09-Oct-18 08:40 AM
typealiasじゃなくてassoctype?
Avatar
t.ae 09-Oct-18 08:43 AM
(さっきできてたのが再現できないので確認中……)
Avatar
koher 09-Oct-18 08:48 AM
似たようなの作れた。 @swift-4.2.4
protocol P { static var Aliased: String.Type { get } } extension P { static var Aliased: String.Type { return String.self } } class A: P {} class B: A { static var Aliased: Double.Type { return Double.self } } let str: String.Type = B.Aliased.self let dbl: Double.Type = B.Aliased.self print(str) print(dbl)
Avatar
swift42 BOT 09-Oct-18 08:48 AM
String Double
Avatar
omochimetaru 09-Oct-18 08:53 AM
なるほど・・・
@swift-4.2.4
protocol P { static var value: Int { get } } extension P { static var value: Int { return 3 } } protocol Q { static var value: Bool { get } } extension Q { static var value: Bool { return true } } class A : P { } class B : A, Q { } class C : B { static var value: String = "str" } let a: Int = C.value let b: Bool = C.value let c: String = C.value print(a, b, c)
Avatar
swift42 BOT 09-Oct-18 08:55 AM
3 true str
Avatar
koher 09-Oct-18 09:03 AM
プロトコル使ったら普通にプロパティオーバーロードできた。 @swift-4.2.4
protocol P { var a: Int { get } } extension P { var a: Int { return 42 } } protocol Q { var a: Bool { get } } extension Q { var a: Bool { return true } } struct S: P, Q {} let s = S() let x: Int = s.a let y: Bool = s.a print(x) print(y)
Avatar
swift42 BOT 09-Oct-18 09:03 AM
42 true
Avatar
koher 09-Oct-18 09:04 AM
うーん、これがありなら普通にプロパティオーバーロードとかジェネリックプロパティとかできてもいい気も? subscript もできるんだし。
それとも意図せずにプロパティオーバーロードができてしまってる?
Avatar
omochimetaru 09-Oct-18 09:05 AM
PとQの var a の型が一緒だとエラーになるし、 PとQを使わずにSに直接2つ書いてもエラーになるし
裏技感がある (edited)
Avatar
rintaro 09-Oct-18 09:12 AM
@swift-4.2.4
protocol P { var a: Int { get set } } extension P { var a: Int { get { return 42 } set {} } } protocol Q { var a: Bool { get set } } extension Q { var a: Bool { get { return true } set {} } } struct S: P, Q {} var s = S() s.a = true as Bool
(edited)
Avatar
swift42 BOT 09-Oct-18 09:12 AM
no output (edited)
Avatar
rintaro 09-Oct-18 09:13 AM
lvalue としてうまく機能しないので、中途半端ですね。
Avatar
omochimetaru 09-Oct-18 09:13 AM
マジかっ
Avatar
rintaro 09-Oct-18 09:14 AM
あ、let だからか?
Avatar
omochimetaru 09-Oct-18 09:14 AM
あ。
Avatar
rintaro 09-Oct-18 09:14 AM
ぉ、うごいた。
Avatar
koher 09-Oct-18 09:18 AM
おおお・・・
Avatar
rintaro 09-Oct-18 09:24 AM
@swift-4.2.4 -O
struct RGBA<Channel> { var red: Channel var green: Channel var blue: Channel var alpha: Channel } let rgbaArray = [RGBA(red: 255, green: 127, blue: 0, alpha: 255)] rgbaArray.withUnsafeBufferPointer { rgbaPointer in print(rgbaPointer[0]) rgbaPointer.withMemoryRebound(to: UInt8.self) { uint8Pointer in print(uint8Pointer[0]) } }
(edited)
🛠 1
Avatar
swiftbot BOT 09-Oct-18 09:24 AM
Author icon rintaro
struct RGBA<Channel> { var red: Channel var green: Channel var blue: Channel var alpha: Channel } let rgbaArray = [RGBA(red: 255, green: 127, blue: 0, alpha: 255)] rgbaArray.withUnsafeBufferPointer { rgbaPointer in print(rgbaPointer[0]) rgbaPointer.withMemoryRebound(to: UInt8.self) { uint8Pointer in print(uint8Pointer[0]) } }
Version:
swift-4.1.1-RELEASE
Output:
Error:
Fatal error: Current stack trace: 0 libswiftCore.so 0x00007f1674d19750 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007f1674a87ad6 <unavailable> + 1366742 2 libswiftCore.so 0x00007f1674cc2383 <unavailable> + 3703683 3 libswiftCore.so 0x00007f1674a87ad6 <unavailable> + 1366742 4 libswiftCore.so 0x00007f1674bf3d80 <unavailable> + 2858368 5 libswiftCore.so 0x00007f1674bbbded <unavailable> + 2629101 6 libswiftCore.so 0x00007f1674bbbc20 UnsafeBufferPointer.withMemoryRebound<A, B>(to:_:) + 42 10 libswiftCore.so 0x00007f1674a81e30 Array.withUnsafeBufferPointer<A>(_:) + 172 12 swift 0x0000000000fed1ce <unavailable> + 12505550 13 swift 0x0000000000ff1692 <unavailable> + 12523154 ...
Avatar
swift42 BOT 09-Oct-18 09:25 AM
RGBA<Int>(red: 255, green: 127, blue: 0, alpha: 255) 255
Avatar
rintaro 09-Oct-18 09:25 AM
-O だと通ると。
Avatar
koher 09-Oct-18 09:25 AM
ええっ!
Avatar
norio_nomura 10-Oct-18 02:41 PM
https://discordapp.com/channels/291054398077927425/291054454793306112/499480778993041411 の様に、ボットへのメンションとコードブロックの始点が同じ行に在っても、正しく解釈する様にしました。 また、コードブロックの始点と終点が行頭になくても認識する様にしました。 @swift-4.2.4
print("hello")
Avatar
swift42 BOT 10-Oct-18 02:41 PM
hello
Avatar
omochimetaru 10-Oct-18 04:59 PM
お!それミスしがちだったので助かります、ありがとうございます
🙂 1
Avatar
omochimetaru 20-Oct-18 01:51 PM
@swift-4.2.4
struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swift42 BOT 20-Oct-18 01:51 PM
exit status: 1 with stderr:
<stdin>:7:9: error: expected 'get', 'set', 'willSet', or 'didSet' keyword to start an accessor definition _modify { ^ <stdin>:23:9: error: cannot pass immutable value as inout argument: 'x' is a get-only property mod(&a.x) ^~~~
Avatar
omochimetaru 20-Oct-18 01:51 PM
@swift-nightly
struct Stone { var x: Int { get { return 1 } _modify { var x: Int = 3 yield &x y = x } } var y: Int = 0 } func mod(_ x: inout Int) { x = 8 } func main() { var a = Stone() mod(&a.x) print(a.y) } main()
Avatar
swiftNightly BOT 20-Oct-18 01:51 PM
8
Avatar
noppe 20-Oct-18 06:27 PM
@swift-4.2.4
print("hello world")
(edited)
Avatar
swift42 BOT 20-Oct-18 06:27 PM
hello world
(edited)
Avatar
norio_nomura 23-Oct-18 05:26 AM
@swift-4.2.4 @swift-4.1.3 -Onone
import Foundation import SwiftBacktrace enablePrettyStackTrace() let group = DispatchGroup() var array = [Int]() DispatchQueue.global().async(group: group) { for i in 0...1000000 { array.append(i) } print("end 1: \(array.count)") } DispatchQueue.global().async(group: group) { for i in 0...1000000 { array.append(i) } print("end 2: \(array.count)") } group.wait()
Avatar
swift42 BOT 23-Oct-18 05:26 AM
exit status: 11 with stderr:
/Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(callStackSymbols<A>(_:transform:)+0x9f) [0x00007ff40d7e71bf] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(backtrace(_:formatter:)+0x102) [0x00007ff40d7e6cd2] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(closure #1 in closure #1 in variable initialization expression of _enablePrettyStackTrace+0x2f) [0x00007ff40d7ebc5f] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(runSignalHandlers()+0x34d) [0x00007ff40d7edbcd] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(signalHandler(signal:)+0x1c4) [0x00007ff40d7ed3a4] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(@objc signalHandler(signal:)+0x9) [0x00007ff40d7ed1d9] /lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x00007ff4150c5390] /lib/x86_64-linux-gnu/libc.so.6(strerror_l+0x500) [0x00007ff41386e870] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized _ArrayBufferProtocol._arrayOutOfPlaceUpdate<A>(_:_:_:_:)+0x16d) [0x00007ff40cd688cd] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array._copyToNewBuffer(oldCount:)+0x3f) [0x00007ff40cd5fbef] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array._copyToNewBuffer(oldCount:)+0x25) [0x00007ff40cd5ffa5] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array.append(_:)+0x78) [0x00007ff40cd5e7c8] /usr/lib/swift/linux/libswiftSwiftOnoneSupport.so(specialized Array.append(_:)+0x10) [0x00007ff40cd5e740] -(+0x0) [0x00007ff4154f57b8] -(+0x0) [0x00007ff4154f55f7] /usr/lib/swift/linux/libdispatch.so(_dispatch_call_block_and_release+0x7) [0x00007ff40cfd48c7] -(+0x0) [0x00007ff4154f57ae]#0 0x000000000410b054 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410b054) #1 0x0000000004108ee2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108ee2) #2 0x000000000410b202 SignalHandler(int) (/usr/bin/swift+0x410b202) #3 0x00007ff4150c5390 __restore_rt (/lib/x86_64-
Avatar
swift41 BOT 23-Oct-18 05:26 AM
exit status: 4 with stderr:
Fatal error: UnsafeMutablePointer.deinitialize with negative count Current stack trace: 0 libswiftCore.so 0x00007f166750b810 _swift_stdlib_reportFatalError + 171 1 libswiftCore.so 0x00007f1667279a86 <unavailable> + 1366662 2 libswiftCore.so 0x00007f16674b4453 <unavailable> + 3703891 3 libswiftCore.so 0x00007f1667279a86 <unavailable> + 1366662 4 libswiftCore.so 0x00007f16673e5ec0 <unavailable> + 2858688 5 libswiftCore.so 0x00007f1667279660 _fatalErrorMessage(_:_:file:line:flags:) + 19 6 libswiftSwiftOnoneSupport.so 0x00007f1664062fda <unavailable> + 163802 7 libswiftSwiftOnoneSupport.so 0x00007f1664058166 <unavailable> + 119142 8 libswiftSwiftOnoneSupport.so 0x00007f1664058100 specialized Array._copyToNewBuffer(oldCount:) + 23 9 libswiftSwiftOnoneSupport.so 0x00007f16640551a2 <unavailable> + 106914 10 libswiftSwiftOnoneSupport.so 0x00007f16640553f0 specialized Array.append(_:) + 16 13 libdispatch.so 0x00007f1663fed977 <unavailable> + 301431 14 libdispatch.so 0x00007f1663ffcd33 <unavailable> + 363827 15 libpthread.so.0 0x00007f166c5626ba <unavailable> + 30394 16 libc.so.6 0x00007f166ad7d3b0 clone + 109 /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(callStackSymbols<A>(_:transform:)+0x87) [0x00007f1664a969c7] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(backtrace(_:formatter:)+0xd8) [0x00007f1664a962d8] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(closure #1 in closure #1 in variable initialization expression of _enablePrettyStackTrace+0x27) [0x00007f1664a90fe7] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.so(runSignalHandlers()+0x324) [0x00007f1664a92e04] /Libraries/.build/x86_64-unknown-linux/debug/libLibraries.s
Avatar
norio_nomura 23-Oct-18 05:29 AM
ああ、CoWはスレッドセーフではないのか。
Avatar
norio_nomura 23-Oct-18 05:41 AM
あいや、メモリが足りないだけ?
Avatar
omochimetaru 25-Oct-18 09:25 AM
@swift-4.2.4
// @escaping だけど同期的にクロージャが実行されるだけの関数 func run(_ body: @escaping () -> Void) { body() } // 値型を非同期的に更新するための機能を提供 struct Updater<Object: AnyObject, Target> { let object: Object let keyPath: ReferenceWritableKeyPath<Object, Target> func update(_ body: (inout Target) throws -> Void) rethrows { try body(&object[keyPath: keyPath]) } } // 値型、これの状態を @escaping をまたいで更新したい struct FooState { var a: Int = 0 mutating func incrementA<Object: AnyObject>(with updater: Updater<Object, FooState>) { run { // @escaping なのでこの中では `self` を更新できない updater.update { state in // Updater を使って更新 state.a += 1 } } } } // FooState を保持する参照型 class Foo { var state: FooState = FooState() func bar() { state.incrementA(with: Updater<Foo, FooState>(object: self, keyPath: \Foo.state)) } } let foo = Foo() foo.bar() print(foo.state.a)
Avatar
swift42 BOT 25-Oct-18 09:25 AM
exit status: 134 with stderr:
Simultaneous accesses to 0x7e0f7e0, but modification requires exclusive access. Previous access (a modification) started at (0x7f4374754523). Current access (a read) started at: 0 libswiftCore.so 0x00007f437005a950 swift_beginAccess + 521 3 libswiftCore.so 0x00007f436ffff1e8 <unavailable> + 3588584 4 libswiftCore.so 0x00007f436feef4a1 <unavailable> + 2475169 5 libswiftCore.so 0x00007f436feef05d <unavailable> + 2474077 6 libswiftCore.so 0x00007f436fef1600 _projectKeyPathReferenceWritable<A, B>(root:keyPath:) + 155 14 swift 0x0000000001043efe <unavailable> + 12861182 15 swift 0x0000000001048022 <unavailable> + 12877858 16 swift 0x00000000004f8b42 <unavailable> + 1018690 17 swift 0x00000000004df0bb <unavailable> + 913595 18 swift 0x00000000004da3f0 <unavailable> + 893936 19 swift 0x000000000048a348 <unavailable> + 566088 20 libc.so.6 0x00007f4372a4e740 __libc_start_main + 240 21 swift 0x0000000000488009 <unavailable> + 557065 Fatal access conflict detected. #0 0x000000000410b054 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410b054) #1 0x0000000004108ee2 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108ee2) #2 0x000000000410b202 SignalHandler(int) (/usr/bin/swift+0x410b202) #3 0x00007f4374324390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007f4372a63428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007f4372a6502a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007f437005a742 (/usr/lib/swift/linux/libswiftCore.so+0x3c7742) #7 0x00007f437005ac38 (/usr/lib/swift/linux/libswiftCore.so+0x3c7c38) #8 0x00007f43747543d9 #9 0x00007f43747549c
Avatar
norio_nomura 31-Oct-18 09:47 AM
@swift-4.2.4 --version
Avatar
swift42 BOT 31-Oct-18 09:47 AM
Swift version 4.2.1 (swift-4.2.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
nekonoki 09-Nov-18 03:12 AM
@swift-nightly
protocol A { associatedtype ARelated } protocol B: A { associatedtype BRelated: Codable } extension B where Self.ARelated: Codable { typealias BRelated = Self.ARelated } struct AImpl: A, B { typealias BRelated = ARelated struct ARelated: Codable { let val: Int } }
(edited)
Avatar
swiftNightly BOT 09-Nov-18 03:13 AM
no output (edited)
Avatar
omochimetaru 09-Nov-18 04:00 AM
@swift-4.2.4
import Foundation print(String(format: "%@", "hello" as NSString))
(edited)
Avatar
swift42 BOT 09-Nov-18 04:00 AM
exit status: 1 with stderr:
<stdin>:3:36: error: argument type 'NSString' does not conform to expected type 'CVarArg' print(String(format: "%@", "hello" as NSString)) ~~~~~~~~^~~~~~~~~~~ as! CVarArg
(edited)
Avatar
norio_nomura 14-Nov-18 02:14 AM
SwiftyMathがswift-DEVELOPMENT-SNAPSHOT-2018-11-13-aでビルドできなくなった。
Avatar
norio_nomura 15-Nov-18 01:44 AM
swift-nightlyボット、swift-DEVELOPMENT-SNAPSHOT-2018-11-14-aで久しぶりにCI通ったけど、ボットとして動かなかったのでswift-DEVELOPMENT-SNAPSHOT-2018-10-03-aまでロールバック。
Avatar
omochimetaru 27-Nov-18 07:26 AM
@swift-4.2.4
import Foundation class Cat { @objc func nya() -> Int { return 3 } } class Dog { @objc func wan() -> Int { return 4 } } func f(_ a: AnyObject) { let x = a.nya() let y = a.wan?() print(type(of: x), x) // Int 3 print(type(of: y), y) // Optional<Int> nil } f(Cat())
Avatar
swift42 BOT 27-Nov-18 07:26 AM
exit status: 134 with stderr:
<stdin>:15:24: warning: expression implicitly coerced from 'Int?' to 'Any' print(type(of: y), y) // Optional<Int> nil ^ <stdin>:15:24: note: provide a default value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ?? <#default value#> <stdin>:15:24: note: force-unwrap the value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ! <stdin>:15:24: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(type(of: y), y) // Optional<Int> nil ^ as Any <unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log <unknown>:0: note: Program used external function 'sel_registerName' which could not be resolved! #0 0x000000000410ac94 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410ac94) #1 0x0000000004108b22 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b22) #2 0x000000000410ae42 SignalHandler(int) (/usr/bin/swift+0x410ae42) #3 0x00007fddc4398390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007fddc2ad7428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007fddc2ad902a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00000000004dfb25 (/usr/bin/swift+0x4dfb25) #7 0x00000000040a35ff llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/bin/swift+0x40a35ff) #8 0x000000000105591b llvm::RuntimeDyldImpl::resolveExternalSymbols() (/usr/bin/swift+0x105591b) #9 0x00000000010542e6 llvm::RuntimeDyldImpl::resolveRelocations() (/usr/bin/swift+0x10542e6) #10 0x0000000001041fcd llvm::MCJIT::finalizeObject() (/usr/bin/swift+0x1041fcd) #11 0x00000000004f88de swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<st
Avatar
omochimetaru 27-Nov-18 07:27 AM
@swift-4.2.4
import Foundation class Cat { @objc func nya() -> Int { return 3 } } class Dog { @objc func wan() -> Int { return 4 } } func f(_ a: AnyObject) { let x = a.nya() let y = a.wan?() print(type(of: x), x) // Int 3 print(type(of: y), y) // Optional<Int> nil }
(edited)
Avatar
swift42 BOT 27-Nov-18 07:27 AM
stderr:
<stdin>:15:24: warning: expression implicitly coerced from 'Int?' to 'Any' print(type(of: y), y) // Optional<Int> nil ^ <stdin>:15:24: note: provide a default value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ?? <#default value#> <stdin>:15:24: note: force-unwrap the value to avoid this warning print(type(of: y), y) // Optional<Int> nil ^ ! <stdin>:15:24: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(type(of: y), y) // Optional<Int> nil ^ as Any
(edited)
Avatar
koher 29-Nov-18 06:00 AM
@swift-4.2.4
import Foundation try! JSONDecoder().decode([Int].self, from: "".data(using: .utf8)!)
(edited)
Avatar
swift42 BOT 29-Nov-18 06:00 AM
exit status: 1 with stderr:
<stdin>:2:6: error: use of unresolved identifier 'JSONDecoder' try! JSONDecoder().decode([Int].self, from: "".data(using: .utf8)!) ^~~~~~~~~~~
Avatar
koher 29-Nov-18 06:32 AM
@swift-4.2.4
import Foundation do { _ = try JSONDecoder().decode([Int].self, from: "".data(using: .utf8)!) } catch let error { print(error) }
Avatar
swift42 BOT 29-Nov-18 06:32 AM
⚠️ [DecodingError.dataCorrupted: The given data was not valid JSON.]
Avatar
norio_nomura 01-Dec-18 03:47 AM
swift-5.0-branchのスナップショットCIが動き始めた。swift50ボットの準備をしないと… https://ci.swift.org/view/swift-5.0-branch/
Avatar
norio_nomura 06-Dec-18 04:16 AM
@swift-tensorflow
#if swift(>=4.2.1) print("4.2.1") #elseif swift(>=4.2) print("4.2") #endif
Avatar
swiftTensorflow BOT 06-Dec-18 04:16 AM
4.2
Avatar
norio_nomura 08-Dec-18 06:02 AM
@swift-5.0.3 @swift-nightly
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swiftNightly BOT 08-Dec-18 06:02 AM
DEVELOPMENT-SNAPSHOT-2018-12-07-a
Avatar
swift50 BOT 08-Dec-18 06:02 AM
5.0-DEVELOPMENT-SNAPSHOT-2018-12-07-a
Avatar
norio_nomura 08-Dec-18 06:14 AM
swift-nightlyボットを更新し、swift-5.0ボットを追加しました。 (edited)
ボット自身をビルドするSwiftのバージョンを固定したため、ツールチェイン不具合の影響を受けずに、ボットが更新される様になりました。
Avatar
norio_nomura 10-Dec-18 02:02 AM
@swift-4.2.4 @swift-5.0.3
import Foundation // column 1 2 3 4 5 6 7 8 9 10 11 // line 1 L I N E 1 _ 6 7 あ \n // line 2 L I N E 2 _ 7 8 9 0 \n // line 3 L I N E 3 _ 8 9 0 1 \n let string = "LINE1_67あ\nLINE2_7890\nLINE3_8901\n" let rangeOfFirstLine = string.lineRange(for: string.startIndex..<string.startIndex) let firstLine = string[rangeOfFirstLine] print(string.distance(from: rangeOfFirstLine.lowerBound, to: rangeOfFirstLine.upperBound)) print(firstLine == "LINE1_67あ\n")
Avatar
swift42 BOT 10-Dec-18 02:02 AM
10 true
Avatar
swift50 BOT 10-Dec-18 02:02 AM
exit status: 4 with stderr:
Fatal error: String index is out of bounds Current stack trace: 0 libswiftCore.so 0x00007f2fb98a75e0 _swift_stdlib_reportFatalError + 69 1 libswiftCore.so 0x00007f2fb97ac1b6 <unavailable> + 3125686 2 libswiftCore.so 0x00007f2fb97ac535 <unavailable> + 3126581 3 libswiftCore.so 0x00007f2fb97b1a39 <unavailable> + 3148345 4 libswiftCore.so 0x00007f2fb97b518b <unavailable> + 3162507 5 libswiftCore.so 0x00007f2fb983a050 String.distance(from:to:) + 9 7 swift 0x0000000000cee8be <unavailable> + 9365694 8 swift 0x0000000000cf2ad2 <unavailable> + 9382610 9 swift 0x000000000051612f <unavailable> + 1138991 10 swift 0x00000000004eafb5 <unavailable> + 962485 11 swift 0x00000000004e6456 <unavailable> + 943190 12 swift 0x000000000048d88e <unavailable> + 579726 13 libc.so.6 0x00007f2fbc4c9740 __libc_start_main + 240 14 swift 0x000000000048b6c9 <unavailable> + 571081 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio-ssl-93eb7dfa/Sources/CNIOOpenSSL/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CCryptoOpenSSL/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBcrypt/include -I /Libraries/.build/checkouts/crypto-36ec1aea/Sources/CBase32/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio-b68c973e/S
Avatar
d_date 13-Dec-18 02:50 PM
@swift-5.0.3
let rain = #"The "rain" in "Spain" falls mainly on the Spaniards."# print(rain)
Avatar
swift50 BOT 13-Dec-18 02:50 PM
The "rain" in "Spain" falls mainly on the Spaniards.
Avatar
d_date 13-Dec-18 02:50 PM
@swift-5.0.3
let keypaths = #"Swift keypaths such as \Person.name hold uninvoked references to properties."# print(keypaths)
Avatar
swift50 BOT 13-Dec-18 02:50 PM
Swift keypaths such as \Person.name hold uninvoked references to properties.
Avatar
d_date 13-Dec-18 02:51 PM
@swift-5.0.3
let answer = 42 let dontpanic = #"The answer to life, the universe, and everything is \#(answer)."# print(dontpanic)
Avatar
swift50 BOT 13-Dec-18 02:51 PM
The answer to life, the universe, and everything is 42.
Avatar
d_date 13-Dec-18 02:52 PM
@swift-5.0.3
let str = ##"My dog said "woof"#gooddog"## print(str)
Avatar
swift50 BOT 13-Dec-18 02:52 PM
My dog said "woof"#gooddog
Avatar
d_date 13-Dec-18 02:53 PM
@swift-5.0.3
let answer = 42 let multiline = #""" The answer to life, the universe, and everything is \#(answer). """# print(multiline)
(edited)
Avatar
swift50 BOT 13-Dec-18 02:53 PM
The answer to life, the universe, and everything is 42.
(edited)
Avatar
d_date 13-Dec-18 02:54 PM
@swift-5.0.3
let answer = 42 let multiline = #""" The answer to life, the universe, and everything is \#(answer). """# print(multiline)
Avatar
swift50 BOT 13-Dec-18 02:54 PM
The answer to life, the universe, and everything is 42.
Avatar
d_date 13-Dec-18 02:55 PM
@swift-5.0.3
let regex2 = #"\\[A-Z]+[A-Za-z]+\.[a-z]+"# print(regex2)
Avatar
swift50 BOT 13-Dec-18 02:55 PM
\\[A-Z]+[A-Za-z]+\.[a-z]+
Avatar
d_date 14-Dec-18 01:48 AM
@swift-5.0.3
let times = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] let finishers1 = times.compactMapValues { Int($0) } let finishers2 = times.compactMapValues(Int.init) print(finishers1) print(finishers2)
Avatar
swift50 BOT 14-Dec-18 01:48 AM
["Robinson": 35, "Hudson": 38, "Clarke": 42] ["Hudson": 38, "Clarke": 42, "Robinson": 35]
Avatar
d_date 14-Dec-18 01:49 AM
@swift-5.0.3
let times = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] let finishers1 = times.compactMapValues { Int($0) } let finishers2 = times.compactMapValues(Int.init) print(finishers1) print(finishers2)
Avatar
swift50 BOT 14-Dec-18 01:49 AM
["Hudson": 38, "Clarke": 42, "Robinson": 35] ["Hudson": 38, "Robinson": 35, "Clarke": 42]
Avatar
d_date 14-Dec-18 01:49 AM
順番変わるのか
Avatar
omochimetaru 14-Dec-18 01:50 AM
辞書になった時点で順番の保証は無いよ、リテラルから辞書になる過程では保持されてるけど
Avatar
d_date 14-Dec-18 01:51 AM
この順番ってどこで決まるの?
Avatar
omochimetaru 14-Dec-18 01:51 AM
内部的なハッシュテーブルのエントリ順
Avatar
d_date 14-Dec-18 01:51 AM
なるほー
Avatar
omochimetaru 14-Dec-18 01:52 AM
OSS FoundationのDictionaryの内部を追っていけば正確にわかりそう
Avatar
rintaro 14-Dec-18 01:53 AM
@swift-5.0.3
let times1 = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] print(times1) let times2 = [ "Hudson": "38", "Clarke": "42", "Robinson": "35", "Hartis": "DNF" ] print(times2)
Avatar
swift50 BOT 14-Dec-18 01:53 AM
["Hartis": "DNF", "Hudson": "38", "Clarke": "42", "Robinson": "35"] ["Robinson": "35", "Hudson": "38", "Clarke": "42", "Hartis": "DNF"]
Avatar
rintaro 14-Dec-18 01:53 AM
インスタンス毎にシードがランダムに変わるので、本当に不定です。
Avatar
omochimetaru 14-Dec-18 01:53 AM
全く同じでも変わるのか。
Avatar
d_date 14-Dec-18 01:56 AM
@swift-5.0.3
let scores = [100, 80, 85] let passCount = scores.count { $0 >= 85 } print(passCount)
(edited)
Avatar
swift50 BOT 14-Dec-18 01:56 AM
2
(edited)
Avatar
omochimetaru 14-Dec-18 01:57 AM
countだ
Avatar
d_date 14-Dec-18 01:59 AM
Swifrt5のproposalを総ナメしてて、荒らしみたいになってるw
@swift-5.0.3
print(3.isMultiple(of: 3))
(edited)
Avatar
swift50 BOT 14-Dec-18 02:05 AM
true
(edited)
Avatar
norio_nomura 14-Dec-18 02:26 AM
@swift-nightly -frontend -repl
:print_decl Result
Avatar
swiftNightly BOT 14-Dec-18 02:26 AM
@_frozen enum Result<Success, Failure> where Failure : Error { case success(Success) case failure(Failure) func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Result<NewSuccess, Failure> func mapError<NewFailure>(_ transform: (Failure) -> NewFailure) -> Result<Success, NewFailure> where NewFailure : Error func flatMap<NewSuccess>(_ transform: (Success) -> Result<NewSuccess, Failure>) -> Result<NewSuccess, Failure> func flatMapError<NewFailure>(_ transform: (Failure) -> Result<Success, NewFailure>) -> Result<Success, NewFailure> where NewFailure : Error func get() throws -> Success } extension Result where Failure == Error { init(catching body: () throws -> Success) } extension Result : Equatable where Success : Equatable, Failure : Equatable { static func == (a: Result<Success, Failure>, b: Result<Success, Failure>) -> Bool } extension Result : Hashable where Success : Hashable, Failure : Hashable { var hashValue: Int { get } func hash(into hasher: inout Hasher) }
Avatar
omochimetaru 14-Dec-18 02:26 AM
おー
Avatar
norio_nomura 14-Dec-18 02:36 AM
@d_date
Swifrt5のproposalを総ナメしてて、荒らしみたいになってるw
問題ないかと。どうしても気になるなら、ダイレクトメッセージをボットに送るとよいです。
Avatar
d_date 14-Dec-18 02:37 AM
ありがとうございます🙏
Avatar
omochimetaru 14-Dec-18 02:39 AM
今あなたがiOS / Swiftの勉強会で聞きたいネタはなんですか2018年末。 その他はリプライください。
これの準備かしら
Avatar
Kishikawa Katsumi 14-Dec-18 02:43 AM
見てるぶんには勉強になるからいいんじゃないかな。
👍 1
Avatar
norio_nomura 14-Dec-18 02:54 AM
ボットへのダイレクトメッセージは練習に使う事を想定しています。 (edited)
ダイレクトメッセージを使うデメリットは、複数のボットへ同時に話しかけられない点かな。
それも、グループDMを使えばいいのかな。 (edited)
ぬ、グループDMを使うにはボットをフレンド登録する必要があるのか。
Avatar
norio_nomura 14-Dec-18 03:07 AM
そしてボットはフレンド登録できないらしい。
Avatar
d_date 14-Dec-18 06:50 AM
@swift-4.2.4 @swift-5.0.3
func doubleOptionalInt() throws -> Int?? { return 3 } let x = try? doubleOptionalInt() print(x as Any)
(edited)
Avatar
swift50 BOT 14-Dec-18 06:50 AM
Optional(Optional(3))
(edited)
Avatar
swift42 BOT 14-Dec-18 06:50 AM
Optional(Optional(Optional(3)))
(edited)
Avatar
d_date 14-Dec-18 07:11 AM
@swift-4.2.4 @swift-5.0.3
enum Result<Value, Error> { case success(Value) case failure(Error) } extension Result: Equatable where Value: Equatable, Error: Equatable { static func == (lhs: Result, rhs: Result) -> Bool { switch (lhs, rhs) { case let (.success(lhs), .success(rhs)): return lhs == rhs case let (.failure(lhs), .failure(rhs)): return lhs == rhs case (.success, .failure), (.failure, .success): return false } } } extension Result: Hashable where Value: Hashable, Error: Hashable { var hashValue: Int { switch self { case let .success(value): return value.hashValue case let .failure(error): return error.hashValue } } } let foo = Result<Int, Never>.success(1) let bar = Result<Int, Never>.success(1) print(foo == bar)
(edited)
Avatar
swift50 BOT 14-Dec-18 07:11 AM
true
(edited)
Avatar
swift42 BOT 14-Dec-18 07:11 AM
exit status: 1 with stderr:
<stdin>:33:11: error: type 'Never' does not conform to protocol 'Equatable' print(foo == bar) ^ <stdin>:33:11: error: '<Self where Self : Equatable> (Self.Type) -> (Self, Self) -> Bool' requires that 'Never' conform to 'Equatable' print(foo == bar) ^ <stdin>:33:11: note: requirement specified as 'Never' : 'Equatable' print(foo == bar) ^ <stdin>:33:11: note: requirement from conditional conformance of 'Result<Int, Never>' to 'Equatable' print(foo == bar) ^
(edited)
Avatar
d_date 14-Dec-18 07:55 AM
@swift-4.2.4
print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga")))
(edited)
Avatar
swift42 BOT 14-Dec-18 07:55 AM
DictionaryLiteral<String, String>(_elements: [("hoge", "fuga")])
(edited)
Avatar
d_date 14-Dec-18 07:56 AM
@swift-5.0.3
print(KeyValuePairs<String, String>(dictionaryLiteral: ("hoge", "fuga")))
(edited)
Avatar
swift50 BOT 14-Dec-18 07:56 AM
["hoge": "fuga"]
(edited)
Avatar
d_date 14-Dec-18 07:57 AM
@swift-5.0.3
print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga")))
Avatar
swift50 BOT 14-Dec-18 07:57 AM
["hoge": "fuga"]
stderr:
<stdin>:2:7: warning: 'DictionaryLiteral' is deprecated: renamed to 'KeyValuePairs' print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga"))) ^ <stdin>:2:7: note: use 'KeyValuePairs' instead print(DictionaryLiteral<String, String>(dictionaryLiteral: ("hoge", "fuga"))) ^~~~~~~~~~~~~~~~~ KeyValuePairs
Avatar
d_date 14-Dec-18 08:02 AM
@swift-5.0.3 @swift-4.2.4
#if swift(<5.1) print("OK") #endif #if compiler(<5.1) print("OK") #endif
Avatar
swift50 BOT 14-Dec-18 08:02 AM
OK OK
Avatar
swift42 BOT 14-Dec-18 08:02 AM
exit status: 1 with stderr:
<stdin>:2:11: error: unexpected platform condition argument: expected a unary comparison, such as '>=2.2' #if swift(<5.1) ^ <stdin>:6:15: error: unexpected platform condition argument: expected a unary comparison, such as '>=2.2' #if compiler(<5.1) ^
Avatar
d_date 14-Dec-18 08:08 AM
@swift-4.2.4 @swift-5.0.3
var x = 1 x.self = 2 print(x.self) // prints 2 let id = \Int.self x[keyPath: id] = 3 print(x[keyPath: id]) // prints 3
(edited)
Avatar
swift42 BOT 14-Dec-18 08:08 AM
exit status: 1 with stderr:
<stdin>:6:11: error: invalid component of Swift key path let id = \Int.self ^ <stdin>:6:10: error: expression type 'WritableKeyPath<_, _>' is ambiguous without more context let id = \Int.self ^~~~~~~~~
(edited)
Avatar
swift50 BOT 14-Dec-18 08:08 AM
2 3
(edited)
Avatar
d_date 14-Dec-18 08:43 AM
@swift-5.0.3 @swift-4.2.4
// Example 1: // Users expect `0xffff_ffff_ffff_ffff` to be coerced to type `UInt`. print(UInt(0xffff_ffff_ffff_ffff as UInt)) print(UInt(0xffff_ffff_ffff_ffff))
(edited)
Avatar
swift50 BOT 14-Dec-18 08:43 AM
18446744073709551615 18446744073709551615
(edited)
Avatar
swift42 BOT 14-Dec-18 08:43 AM
exit status: 1 with stderr:
<stdin>:6:12: error: integer literal '18446744073709551615' overflows when stored into 'Int' print(UInt(0xffff_ffff_ffff_ffff)) ^
(edited)
Avatar
masakihori 15-Dec-18 05:52 AM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4
import Foundation if [1] == [1] { print("OK") }
(edited)
Avatar
swift42 BOT 15-Dec-18 05:52 AM
OK
(edited)
Avatar
swift40 BOT 15-Dec-18 05:52 AM
OK
(edited)
Avatar
swift41 BOT 15-Dec-18 05:52 AM
OK
(edited)
Avatar
swift42 BOT 16-Dec-18 02:59 AM
exit status: 1 with stderr:
<stdin>:4:8: error: ambiguous use of operator '==' if [1] == [1] { ^ Foundation.IndexPath:28:24: note: found this candidate public static func == (lhs: Foundation.IndexPath, rhs: Foundation.IndexPath) -> Bool ^ Foundation.IndexSet:2:24: note: found this candidate public static func == (lhs: Foundation.IndexSet, rhs: Foundation.IndexSet) -> Bool ^
Avatar
swift41 BOT 16-Dec-18 02:59 AM
exit status: 1 with stderr:
<stdin>:4:8: error: ambiguous use of operator '==' if [1] == [1] { ^ Foundation.IndexPath:28:24: note: found this candidate public static func == (lhs: Foundation.IndexPath, rhs: Foundation.IndexPath) -> Bool ^ Foundation.IndexSet:2:24: note: found this candidate public static func == (lhs: Foundation.IndexSet, rhs: Foundation.IndexSet) -> Bool ^
Avatar
swift40 BOT 16-Dec-18 02:59 AM
exit status: 1 with stderr:
<stdin>:4:8: error: ambiguous use of operator '==' if [1] == [1] { ^ Foundation.IndexPath:46:24: note: found this candidate public static func ==(lhs: Foundation.IndexPath, rhs: Foundation.IndexPath) -> Bool ^ Foundation.IndexSet:2:24: note: found this candidate public static func ==(lhs: Foundation.IndexSet, rhs: Foundation.IndexSet) -> Bool ^
Avatar
masakihori 16-Dec-18 03:00 AM
なるほど
Avatar
norio_nomura 16-Dec-18 03:48 AM
@swift-4.2.4
import SwiftBacktrace print(swiftDemangleName("$S13ExampleNumber6isEven6numberSbSi_tF")) print(swiftSimplifiedDemangleName("$S13ExampleNumber6isEven6numberSbSi_tF"))
(edited)
Avatar
swift42 BOT 16-Dec-18 03:48 AM
ExampleNumber.isEven(number: Swift.Int) -> Swift.Bool isEven(number:)
(edited)
Avatar
d_date 17-Dec-18 06:11 AM
@swift-5.0.3
import Foundation public extension String.StringInterpolation { mutating func appendInterpolation(_ value: Date, _ formatter: DateFormatter) { appendLiteral(formatter.string(from: value)) } } public extension DateFormatter { static func format(date: Style, time: Style) -> DateFormatter { let formatter = DateFormatter() formatter.locale = Locale.current (formatter.dateStyle, formatter.timeStyle) = (date, time) return formatter } } let formatter = DateFormatter.format(date: .none, time: .long) print("\(Date(), formatter)")
Avatar
swift50 BOT 17-Dec-18 06:11 AM
3:11:18 PM GMT+9
Avatar
d_date 17-Dec-18 06:11 AM
あー便利だこれ
@swift-5.0.3
import Foundation public extension String.StringInterpolation { mutating func appendInterpolation(_ value: Date, _ formatter: DateFormatter) { appendLiteral(formatter.string(from: value)) } } public extension DateFormatter { static func format(date: Style, time: Style, locale: Locale = .current) -> DateFormatter { let formatter = DateFormatter() formatter.locale = locale (formatter.dateStyle, formatter.timeStyle) = (date, time) return formatter } } let formatter = DateFormatter.format(date: .none, time: .long) print("\(Date(), formatter)")
Avatar
swift50 BOT 17-Dec-18 06:17 AM
3:17:13 PM GMT+9
Avatar
norio_nomura 20-Dec-18 03:47 AM
@swift-5.0.3 -frontend -repl
:print_decl Result
Avatar
swift50 BOT 20-Dec-18 03:47 AM
@_frozen enum Result<Success, Failure> where Failure : Error { case success(Success) case failure(Failure) func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> Result<NewSuccess, Failure> func mapError<NewFailure>(_ transform: (Failure) -> NewFailure) -> Result<Success, NewFailure> where NewFailure : Error func flatMap<NewSuccess>(_ transform: (Success) -> Result<NewSuccess, Failure>) -> Result<NewSuccess, Failure> func flatMapError<NewFailure>(_ transform: (Failure) -> Result<Success, NewFailure>) -> Result<Success, NewFailure> where NewFailure : Error func get() throws -> Success } extension Result where Failure == Error { init(catching body: () throws -> Success) } extension Result : Equatable where Success : Equatable, Failure : Equatable { static func == (a: Result<Success, Failure>, b: Result<Success, Failure>) -> Bool } extension Result : Hashable where Success : Hashable, Failure : Hashable { var hashValue: Int { get } func hash(into hasher: inout Hasher) }
Avatar
d_date 20-Dec-18 06:34 AM
自分でResultをまんま実装すると、
extension Result where Failure == Error { init(catching body: () throws -> Success) }
でコンパイルエラーになるんですよね
Avatar
omochimetaru 20-Dec-18 06:36 AM
それは、 protocol P に対して P型(existential)それ自体は P に準拠しないから
<Failure : Error(これはプロトコル) > にたいして Failure == Error ( これはExistential)
を制約しても意味ないから、間違ってるよってエラーです
このプロポーザルによって、
Error(exis)型それ自体もErrorプロトコルであるように、
変更されるから
その言語仕様の変更とセットじゃないと意味がないコード。
Avatar
rintaro 20-Dec-18 06:39 AM
@swift-5.0.3
enum MyResult<Success, Failure: Error> { case success(Success) case failure(Failure) } extension MyResult where Failure == Error { init(catching body: () throws -> Success) { do { self = .success(try body()) } catch { self = .failure(error) } } } print(type(of: MyResult { 1 }))
Avatar
swift50 BOT 20-Dec-18 06:39 AM
MyResult<Int, Error>
Avatar
d_date 20-Dec-18 06:44 AM
そういうことかー
@swift-5.0.3
print(type(of: Result { 1 }))
Avatar
swift50 BOT 20-Dec-18 06:45 AM
Result<Int, Error>
Avatar
d_date 20-Dec-18 06:45 AM
ResultはSwift5に入ったからこれも動くと。
Avatar
omochimetaru 20-Dec-18 06:46 AM
プロポーザルの第二回レビューでコアチームの人が言い出して導入されてちょっとびっくりした。
あ、そうだね、サードパーティのResultにも、AnyErrorが提供されていることがあるけど、それが不要になるよ。
Avatar
d_date 20-Dec-18 06:46 AM
やったね〜〜
Avatar
omochimetaru 20-Dec-18 06:47 AM
あと Never : Error も入るから、 NoError も不要に。
Avatar
d_date 20-Dec-18 06:48 AM
NeverのconformanceはResultに向けたもので、しばらくは使われないのかと思ったけど、ちゃんとResultも入ったので安心。
Avatar
d_date 20-Dec-18 07:07 AM
@swift-5.0.3
let foo = Result<Int, Never>.success(1) let bar = Result<Int, Never>.success(1) print(foo == bar)
Avatar
swift50 BOT 20-Dec-18 07:07 AM
true
Avatar
omochimetaru 21-Dec-18 04:04 PM
@swift-5.0.3
print(#"\a\b"#)
Avatar
swift50 BOT 21-Dec-18 04:04 PM
\a\b
Avatar
omochimetaru 21-Dec-18 04:04 PM
@swift-5.0.3
print(###"aaa"bbb#ccc"###)
Avatar
swift50 BOT 21-Dec-18 04:04 PM
aaa"bbb#ccc
Avatar
nekonoki 25-Dec-18 06:10 AM
@swift-4.2.4 @swift-5.0.3
import Foundation print(UUID().uuidString)
(edited)
Avatar
swift50 BOT 25-Dec-18 06:10 AM
f9db6c73-cdf1-472d-89a6-f406f7d194eb
(edited)
Avatar
swift42 BOT 25-Dec-18 06:10 AM
2F2A909C-271D-4144-943F-158426CFC90E
(edited)
Avatar
rintaro 25-Dec-18 08:22 AM
@swiftbot
class Base { func foo(x: Int = 12) {} } class Derived : Base { override func foo(x: Int = 42) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
(edited)
🛠 1
Avatar
swiftbot BOT 25-Dec-18 08:22 AM
(edited)
Author icon rintaro
class Base { func foo(x: Int = 12) {} } class Derived : Base { override func foo(x: Int = 42) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
Version:
swift-4.2.1-RELEASE
Output:
12 42
Error:
Avatar
rintaro 25-Dec-18 08:23 AM
理解はできるけど、釈然としない。
Avatar
tarunon 25-Dec-18 08:24 AM
仕様も解るし気持ちもわかる…
Avatar
tarunon 25-Dec-18 08:34 AM
@swift-4.2.4
class Base { class var defaultX: Int { return 12 } func foo(x: Int = defaultX) {} } class Derived : Base { override class var defaultX: Int { return 42 } override func foo(x: Int = defaultX) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
Avatar
swift42 BOT 25-Dec-18 08:34 AM
12 42
Avatar
tarunon 25-Dec-18 08:34 AM
これでもダメなんですね
Avatar
rintaro 25-Dec-18 08:35 AM
そうなんですよね。僕もちょうどそれ試してた。
@swift-4.2.4
class Base { class func getDefaultFooX() -> Int { return 12 } func foo(x: Int = getDefaultFooX()) {} } class Derived : Base { override class func getDefaultFooX() -> Int { return 42 } override func foo(x: Int = getDefaultFooX()) { print(x) } } func test1(obj: Base) { obj.foo() } func test2(obj: Derived) { obj.foo() } test1(obj: Derived()) test2(obj: Derived())
Avatar
swift42 BOT 25-Dec-18 08:35 AM
12 42
Avatar
rintaro 25-Dec-18 08:37 AM
https://forums.swift.org/t/pitch-allow-default-parameter-overrides/10673/5 Jordan のこのコメントをもって、最初のやつ以外はバグとしたいお気持ち
Adam and Xiaodi have it correct, and it’s always possible to get the effect you want by adding an overridable method to mySuperClass (something like ‘defaultStatement()’).
とはいえコメントの意図としては
class Base { func getDefaultFooX() -> Int { return 12 } func foo(x: Int? = nil) { let x = x ?? getDefaultFooX() print(x) } } class Derived : Base { override func getDefaultFooX() -> Int { return 42 } }
という事なのでしょうね。
(edited)
Avatar
tarunon 25-Dec-18 08:45 AM
フムー
Avatar
omochimetaru 25-Dec-18 04:10 PM
面白い
Avatar
norio_nomura 07-Jan-19 01:15 AM
@swift-4.2.4 @swift-5.0.3 @swift-nightly
import Foundation let a = Float80.init(6.8523015e+5) let b = 6.8523015e+5 as Float80 print(a) print(b) print(a == b)
Avatar
swift50 BOT 07-Jan-19 01:15 AM
685230.1500000000233 685230.15 false
Avatar
swift42 BOT 07-Jan-19 01:15 AM
685230.1500000000233 685230.15 false
Avatar
swiftNightly BOT 07-Jan-19 01:15 AM
685230.1500000000233 685230.15 false
Avatar
omochimetaru 07-Jan-19 01:16 AM
あれ?最近それ同じになってませんでしたっけ
Avatar
norio_nomura 07-Jan-19 01:17 AM
Float80だけバグってる。
Float80.init(_ other: Double)が呼ばれてる。
Avatar
omochimetaru 07-Jan-19 01:26 AM
64bit経由になってるんですか、それはまずいですねw
Avatar
norio_nomura 07-Jan-19 01:29 AM
Avatar
omochimetaru 07-Jan-19 01:29 AM
えらい
Avatar
norio_nomura 08-Jan-19 01:18 AM
@swift-4.2.4 @swift-5.0.3
import Foundation let a = Float80(6.8523015e+5) let b = 6.8523015e+5 as Float80 print(a) print(b) print(a == b)
(edited)
Avatar
swift42 BOT 08-Jan-19 01:18 AM
685230.1500000000233 685230.15 false
(edited)
Avatar
swift50 BOT 08-Jan-19 01:18 AM
685230.15 685230.15 true
(edited)
Avatar
norio_nomura 08-Jan-19 01:18 AM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
DoubleFloatはSE-0213導入前の挙動でも問題が起きていなかったと。
Avatar
norio_nomura 12-Jan-19 12:01 AM
@swift-4.2.4 -frontend -repl
protocol P { func hoge(_ a: Int) func hoge(_ a: String) } extension P { func hoge(_ a: Int) {} } struct S : P { func hoge<X>(_ a: X) {} } let s = S() :constraints debug on s.hoge(1) s.hoge("a")
Avatar
swift42 BOT 12-Jan-19 12:01 AM
// s : S = REPL.S()
stderr:
---Constraint solving for the expression at [<REPL Input>:1:1 - line:1:9]--- (overload set choice binding $T0 := S) ---Initial constraints for the given expression--- (call_expr type='$T3' location=<REPL Input>:1:3 range=[<REPL Input>:1:1 - line:1:9] arg_labels=_: (unresolved_dot_expr type='$T1' location=<REPL Input>:1:3 range=[<REPL Input>:1:1 - line:1:3] field 'hoge' function_ref=single (declref_expr type='S' location=<REPL Input>:1:1 range=[<REPL Input>:1:1 - line:1:1] decl=REPL.(file).s@<REPL Input>:1:5 direct_to_storage function_ref=unapplied)) (paren_expr type='($T2)' location=<REPL Input>:1:8 range=[<REPL Input>:1:7 - line:1:9] (integer_literal_expr type='$T2' location=<REPL Input>:1:8 range=[<REPL Input>:1:8 - line:1:8] value=1))) Score: 0 0 0 0 0 0 0 0 0 0 0 Type Variables: $T0 [lvalue allowed] as S @ locator@0x8a91c18 [DeclRef@<REPL Input>:1:1] $T1 [lvalue allowed] subtype_of_existential involves_type_vars bindings={} @ locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member] $T2 fully_bound literal=3 involves_type_vars bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x8a91df0 [IntegerLiteral@<REPL Input>:1:8] $T3 fully_bound subtype_of_existential involves_type_vars bindings={} @ locator@0x8a91e98 [Call@<REPL Input>:1:3 -> function result] Active Constraints: Inactive Constraints: disjunction [[locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member]]]:$T1 bound to decl REPL.(file).S.hoge@<REPL Input>:2:12 : <X> (S) -> (X) -> () at <REPL Input>:2:12 [[locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member]]]; or $T1 bound to decl REPL.(file).P.hoge@<REPL Input>:2:12 : <Self where Self : P> (Self) -> (Int) -> () at <REPL Input>:2:12 [[locator@0x8a91c98 [UnresolvedDot@<REPL Input>:1:3 -> member]]]; $T2 literal conforms to ExpressibleByIntegerLiteral [[locator@0x8a91df0 [IntegerLiteral@<REPL Input>:1:8]]]; ($T2) -> $T3 applicable fn $T1 [[loc
Avatar
omochimetaru 12-Jan-19 12:01 AM
え、こわれた。
<X>がプロトコルじゃなくて普通のジェネリクスってだけ?
Avatar
norio_nomura 12-Jan-19 12:02 AM
<X> (S) -> (X) -> ()<Self where Self : P> (Self) -> (Int) -> () を比較して後者を選んでるぽいね。
Avatar
omochimetaru 12-Jan-19 12:03 AM
あ。壊れてるんじゃなくてREPL出力か。
なるほど
Avatar
norio_nomura 12-Jan-19 12:04 AM
:constraints debug ons.hoge(1)がどう選択されているか出力してる。
Avatar
omochimetaru 12-Jan-19 12:04 AM
プロトコルは関係なくてよりシンプルには<X>よりextension Pが優先しているんですね
Avatar
norio_nomura 12-Jan-19 12:05 AM
長いログをアップロードするのに使ってる https://ptpb.pw が死んでるぽい。
コードをコピーして pbpaste|swift -frontend -repl として見るのが簡単。 (edited)
Avatar
omochimetaru 12-Jan-19 12:08 AM
お、できた、長い。
オーバーロード選択規則の中にジェネリクスが弱い則があるけど
自前定義かdefault extensionかっていう部分は無いのかな
Avatar
norio_nomura 12-Jan-19 12:11 AM
無さげ
Avatar
bannzai 13-Jan-19 03:48 PM
@swift-nightly -frontend -emit-syntax
import Foundation public class TestFunctionDeclDefaultArgument { func multipleArgument(argument1: Int = 1, argument2: String = "string") { } }
@swift-nightly -frontend -emit-syntax
import Foundation public class TestFunctionDeclDefaultArgument { func multipleArgument(argument1: Int = 1, argument2: String = "string") { } }
Avatar
swiftNightly BOT 13-Jan-19 03:49 PM
{"id":49,"kind":"SourceFile","layout":[{"id":48,"kind":"CodeBlockItemList","layout":[{"id":6,"kind":"CodeBlockItem","layout":[{"id":5,"kind":"ImportDecl","layout":[null,null,{"id":1,"tokenKind":{"kind":"kw_import"},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,{"id":4,"kind":"AccessPath","layout":[{"id":3,"kind":"AccessPathComponent","layout":[{"id":2,"tokenKind":{"kind":"identifier","text":"Foundation"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},null,null],"presence":"Present"},{"id":46,"kind":"CodeBlockItem","layout":[{"id":45,"kind":"ClassDecl","layout":[null,{"id":9,"kind":"ModifierList","layout":[{"id":8,"kind":"DeclModifier","layout":[{"id":7,"tokenKind":{"kind":"kw_public"},"leadingTrivia":[{"kind":"Newline","value":2}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null],"presence":"Present"}],"presence":"Present"},{"id":10,"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":11,"tokenKind":{"kind":"identifier","text":"TestFunctionDeclDefaultArgument"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"id":44,"kind":"MemberDeclBlock","layout":[{"id":12,"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":42,"kind":"MemberDeclList","layout":[{"id":41,"kind":"MemberDeclListItem","layout":[{"id":40,"kind":"FunctionDecl","layout":[null,null,{"id":13,"tokenKind":{"kind":"kw_func"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":14,"tokenKind":{"kind":"identifier","text":"multipleArgument"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null,{"id":36,"kind":"FunctionSignature","layout"
Avatar
bannzai 13-Jan-19 03:49 PM
めっちゃ便利
@swift-nightly -frontend -emit-syntax
import Foundation public class TestFunctionDeclNoReturn { func twoArgumentNoReturn(argument1: Int, argument2: String) { } }
Avatar
swiftNightly BOT 13-Jan-19 03:52 PM
{"id":42,"kind":"SourceFile","layout":[{"id":41,"kind":"CodeBlockItemList","layout":[{"id":6,"kind":"CodeBlockItem","layout":[{"id":5,"kind":"ImportDecl","layout":[null,null,{"id":1,"tokenKind":{"kind":"kw_import"},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,{"id":4,"kind":"AccessPath","layout":[{"id":3,"kind":"AccessPathComponent","layout":[{"id":2,"tokenKind":{"kind":"identifier","text":"Foundation"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},null,null],"presence":"Present"},{"id":39,"kind":"CodeBlockItem","layout":[{"id":38,"kind":"ClassDecl","layout":[null,{"id":9,"kind":"ModifierList","layout":[{"id":8,"kind":"DeclModifier","layout":[{"id":7,"tokenKind":{"kind":"kw_public"},"leadingTrivia":[{"kind":"Newline","value":2}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null],"presence":"Present"}],"presence":"Present"},{"id":10,"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":11,"tokenKind":{"kind":"identifier","text":"TestFunctionDeclNoReturn"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"id":37,"kind":"MemberDeclBlock","layout":[{"id":12,"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"id":35,"kind":"MemberDeclList","layout":[{"id":34,"kind":"MemberDeclListItem","layout":[{"id":33,"kind":"FunctionDecl","layout":[null,null,{"id":13,"tokenKind":{"kind":"kw_func"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"id":14,"tokenKind":{"kind":"identifier","text":"twoArgumentNoReturn"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null,{"id":29,"kind":"FunctionSignature","layout":[{"
Avatar
norio_nomura 17-Jan-19 05:17 AM
@swift-4.2.4 @swift-5.0.3 @swift-nightly
import Foundation print(NSNumber(value: 1.2 as Float).description)
Avatar
swift42 BOT 17-Jan-19 05:17 AM
1.20000004768372
Avatar
swiftNightly BOT 17-Jan-19 05:17 AM
exit status: 4 with stderr:
Fatal error: Unknown NSNumber Type: file /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift-corelibs-foundation/Foundation/NSNumber.swift, line 1041 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main -lLibraries #0 0x00000000047d58a4 PrintStackTraceSignalHan
Avatar
swift50 BOT 17-Jan-19 05:17 AM
exit status: 4 with stderr:
Fatal error: Unknown NSNumber Type: file /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift-corelibs-foundation/Foundation/NSNumber.swift, line 1041 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main -lLibraries #0 0x0000000004621134 PrintStackTraceSigna
Avatar
tarunon 17-Jan-19 10:36 AM
@swift-4.1.3
let data = """ {"data": 9223372036854775808} """ struct Foo: Codable { var data: UInt64 } import Foundation print(try! JSONDecoder().decode(Foo.self, from: data.data(using: .utf8)!))
Avatar
swift41 BOT 17-Jan-19 10:36 AM
Foo(data: 9223372036854775807)
Avatar
omochimetaru 17-Jan-19 10:37 AM
Avatar
norio_nomura 17-Jan-19 10:42 AM
macOSだと問題ないね。
$ pbpaste let data = """ {"data": 9223372036854775808} """ struct Foo: Codable { var data: UInt64 } import Foundation print(try! JSONDecoder().decode(Foo.self, from: data.data(using: .utf8)!))% $ pbpaste|xcrun --toolchain org.swift.40320171205a swift - Foo(data: 9223372036854775808) $ pbpaste|xcrun --toolchain org.swift.41320180727a swift - Foo(data: 9223372036854775808) $ pbpaste|xcrun --toolchain org.swift.42120181030a swift - Foo(data: 9223372036854775808) $ pbpaste|xcrun --toolchain org.swift.5020190116a swift - Foo(data: 9223372036854775808)
Avatar
tarunon 17-Jan-19 10:42 AM
ですね
Avatar
norio_nomura 17-Jan-19 11:13 AM
@swift-4.2.4 @swift-5.0.3
let data = """ {"data": 9223372036854775808} """ import Foundation dump(try! JSONSerialization.jsonObject(with: data.data(using: .utf8)!))
Avatar
swift50 BOT 17-Jan-19 11:13 AM
▿ 1 key/value pair ▿ (2 elements) - key: "data" ▿ value: 9223372036854775808 #0 - super: Foundation.NSValue - super: Foundation.NSObject ▿ _base: Foundation._CFInfo - info: 5766 - pad: 0 - _pad: 0
Avatar
swift42 BOT 17-Jan-19 11:13 AM
▿ 1 key/value pair ▿ (2 elements) - key: "data" ▿ value: 9223372036854775807 #0 - super: Foundation.NSValue - super: Foundation.NSObject ▿ _base: Foundation._CFInfo - info: 5763 - pad: 0 - _pad: 9223372036854775807
Avatar
nekonoki 18-Jan-19 01:42 AM
@swift-4.2.4 @swift-5.0.3
class Entity<Base> {} class Tweet: Entity<Tweet> {} print(Tweet())
Avatar
swift50 BOT 18-Jan-19 01:42 AM
main.Tweet
Avatar
swift42 BOT 18-Jan-19 01:43 AM
execution timeout with no output
Avatar
omochimetaru 18-Jan-19 01:43 AM
マジか
そんな簡単な死あるの知らなかった。
Avatar
nekonoki 18-Jan-19 02:37 AM
コンパイルまでは問題なくてアクセスすると死んじゃうんですよね。。
Avatar
tarunon 18-Jan-19 07:32 AM
これJavaのコードでたまに見るパターンぽい
Avatar
omochimetaru 18-Jan-19 07:33 AM
C++でもやるね
Swiftの場合 protocol の中で Self が使えるから、不要な事が多い。
Avatar
tarunon 18-Jan-19 07:33 AM
前までこれコンパイル出来なかった気がするんだけど、今通っちゃうんですね
Avatar
Avatar
tarunon 18-Jan-19 07:34 AM
名前w
Avatar
omochimetaru 18-Jan-19 07:34 AM
CRTP
Avatar
bannzai 20-Jan-19 06:35 AM
@swift-4.2.4 -frontend -emit-syntax
import Foundation public class TestFunctionDeclDefaultArgument { func multipleArgument(argument1: Int = 1, argument2: String = "string") { } }
Avatar
swift42 BOT 20-Jan-19 06:35 AM
{"kind":"SourceFile","layout":[{"kind":"CodeBlockItemList","layout":[{"kind":"CodeBlockItem","layout":[{"kind":"ImportDecl","layout":[null,null,{"tokenKind":{"kind":"kw_import"},"leadingTrivia":[{"kind":"Newline","value":1}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,{"kind":"AccessPath","layout":[{"kind":"AccessPathComponent","layout":[{"tokenKind":{"kind":"identifier","text":"Foundation"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},null],"presence":"Present"},{"kind":"CodeBlockItem","layout":[{"kind":"ClassDecl","layout":[null,{"kind":"ModifierList","layout":[{"kind":"DeclModifier","layout":[{"tokenKind":{"kind":"kw_public"},"leadingTrivia":[{"kind":"Newline","value":2}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"kind":"TokenList","layout":[],"presence":"Present"}],"presence":"Present"}],"presence":"Present"},{"tokenKind":{"kind":"kw_class"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"tokenKind":{"kind":"identifier","text":"TestFunctionDeclDefaultArgument"},"leadingTrivia":[],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},null,null,null,{"kind":"MemberDeclBlock","layout":[{"tokenKind":{"kind":"l_brace"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"kind":"DeclList","layout":[{"kind":"FunctionDecl","layout":[null,null,{"tokenKind":{"kind":"kw_func"},"leadingTrivia":[{"kind":"Newline","value":1},{"kind":"Space","value":4}],"trailingTrivia":[{"kind":"Space","value":1}],"presence":"Present"},{"tokenKind":{"kind":"identifier","text":"multipleArgument"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},null,{"kind":"FunctionSignature","layout":[{"kind":"ParameterClause","layout":[{"tokenKind":{"kind":"l_paren"},"leadingTrivia":[],"trailingTrivia":[],"presence":"Present"},{"kind":"FunctionParameterList","layout":[{"kind":"Func
Avatar
norio_nomura 20-Jan-19 06:41 AM
ああ、ある程度大きい出力で同じ内容を貼り付けようとすると、ptpb.pwが弾くのかも。
Avatar
bannzai 20-Jan-19 06:43 AM
おお、なるほどね。あざすあざす
Avatar
norio_nomura 20-Jan-19 06:58 AM
-emit-syntax用にprettyPrintが欲しくなるな。
Avatar
masakihori 24-Jan-19 01:51 AM
@swift-4.2.4
import Foundation let u = NSURL()
Avatar
swift42 BOT 24-Jan-19 01:51 AM
exit status: 1 with stderr:
<stdin>:4:9: error: cannot invoke initializer for type 'NSURL' with no arguments let u = NSURL() ^ <stdin>:4:9: note: overloads for 'NSURL' exist with these partially matching parameter lists: (coder: NSCoder), (fileURLWithPath: String, isDirectory: Bool, relativeTo: URL?), (fileURLWithPath: String, relativeTo: URL?), (fileURLWithPath: String, isDirectory: Bool), (fileURLWithPath: String), (fileURLWithFileSystemRepresentation: UnsafePointer<Int8>, isDirectory: Bool, relativeTo: URL?), (string: String), (string: String, relativeTo: URL?), (dataRepresentation: Data, relativeTo: URL?), (absoluteURLWithDataRepresentation: Data, relativeTo: URL?) let u = NSURL() ^
Avatar
masakihori 24-Jan-19 01:54 AM
macOS以外では 正しくエラーになるのか
Avatar
masakihori 25-Jan-19 07:19 AM
@swift-5.0.3
import Foundation let u = NSURL()
Avatar
swift50 BOT 25-Jan-19 07:19 AM
exit status: 1 with stderr:
<stdin>:3:9: error: cannot invoke initializer for type 'NSURL' with no arguments let u = NSURL() ^ <stdin>:3:9: note: overloads for 'NSURL' exist with these partially matching parameter lists: (coder: NSCoder), (fileURLWithPath: String, isDirectory: Bool, relativeTo: URL?), (fileURLWithPath: String, relativeTo: URL?), (fileURLWithPath: String, isDirectory: Bool), (fileURLWithPath: String), (fileURLWithFileSystemRepresentation: UnsafePointer<Int8>, isDirectory: Bool, relativeTo: URL?), (string: String), (string: String, relativeTo: URL?), (dataRepresentation: Data, relativeTo: URL?), (absoluteURLWithDataRepresentation: Data, relativeTo: URL?) let u = NSURL() ^
Avatar
norio_nomura 30-Jan-19 12:06 AM
@swift-4.1.3 @swift-4.2.4 @swift-5.0.3
let café = "café" let index = café.utf8.index(before: café.utf8.endIndex) // The last byte. let before = String(café[..<index]) let after = String(café[index...]) print(before + after) // “café” print(after.utf8.count) // 2 bytes?!?
Avatar
swift42 BOT 30-Jan-19 12:06 AM
café 2
Avatar
swift41 BOT 30-Jan-19 12:06 AM
café 2
Avatar
swift50 BOT 30-Jan-19 12:06 AM
café 1
Avatar
norio_nomura 30-Jan-19 12:06 AM
🤔
Avatar
norio_nomura 30-Jan-19 12:26 AM
Swift 5.0のStringの挙動、不安になってきた… https://bugs.swift.org/browse/SR-9802
Avatar
omochimetaru 30-Jan-19 12:33 AM
なんで2
ああ、utf8で1つ戻って文字の途中に突っ込んだのか
swift4では文字頭までもどったから2で、swift5はutf8の位置がモテるから1か
これはこれで良いのでは?
Avatar
norio_nomura 30-Jan-19 12:59 AM
どっちが正しいのかはおいても、挙動が変わってるのが。
Avatar
omochimetaru 30-Jan-19 01:06 AM
やっぱり5の挙動が変に思えてきました
いちどbeforeとafterはStringになってるのに
afterが保持してるのはutf8の後続バイトだ
StringはCharacterに分けられる場所でしか切り出せないのが良いと思う
Avatar
norio_nomura 30-Jan-19 01:25 AM
この変更があっさり入っているという事は、この挙動をテストするコードがずっとなかったって事?
Avatar
omochimetaru 30-Jan-19 01:30 AM
たしかにどうなんだろう トリッキーといえばトリッキーだし、いかにもテストケースにしたいやつではありますよね
Avatar
norio_nomura 30-Jan-19 01:34 AM
探してみたけど、無さげ。
Avatar
norio_nomura 31-Jan-19 12:01 AM
@swift-4.2.4 @swift-5.0.3
func printUnicodeScalars<S: StringProtocol>(_ string: S) { print(string.unicodeScalars.map { "\\u{\(String($0.value, radix: 16))}" }.joined()) } // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" printUnicodeScalars(family) let utf16Index = family.utf16.index(before: family.utf16.endIndex) let utf16Before = String(family[..<utf16Index]) printUnicodeScalars(utf16Before) let utf16After = String(family[utf16Index...]) printUnicodeScalars(utf16After) printUnicodeScalars(utf16Before + utf16After) print(utf16After.utf16.count)
(edited)
Avatar
swift42 BOT 31-Jan-19 12:01 AM
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{fffd} \u{fffd} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} 1
(edited)
Avatar
swift50 BOT 31-Jan-19 12:01 AM
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d} \u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} 2
(edited)
Avatar
norio_nomura 31-Jan-19 12:02 AM
Swift 4以前のString.UTF16View.index(before:) は、Characterの途中のIndexを指すこともあったぽい。 (edited)
Avatar
norio_nomura 31-Jan-19 12:21 AM
これはSwift 5のString.UTF8View.index(before:)と同等の挙動。
Avatar
norio_nomura 31-Jan-19 12:32 AM
とりあえず、Swift 4とSwift 5でString.UTF16ViewString.UTF8View両方のindex(before:)の挙動が違う。
Avatar
omochimetaru 31-Jan-19 01:42 AM
Swift4の場合は  末尾のU+1F466がサロゲートペアでちぎれて、どちらも表示は不正文字FFFDになるが、ちぎれたまま保持されてて、くっつけると繋がって戻る Swift5の場合は  末尾のU+1F466がペアを保ってちぎれて、どちらもCharacter境界をたもってて、countは2になっていて、くっつけるとつながって戻る という感じか (edited)
Avatar
rintaro 31-Jan-19 01:42 AM
https://bugs.swift.org/browse/SR-6161 これを思い出しました。
👀 1
これも4と5で挙動がちがう。 (edited)
Avatar
norio_nomura 31-Jan-19 01:43 AM
挙動が一貫してないよね。
Avatar
omochimetaru 31-Jan-19 01:44 AM
Swift5においてUTF-16に限っては、Character境界までインデックスが畳み込まれる挙動が追加実装されたけど、UTF-8は不正位置でちぎれる
SE‐0180 came up again during the review of SE‐0241, which seeks to do some damage control. I was not around during the original review of SE‐0180. I wish I was, because it has become the only accepted evolution proposal I have ever wished could be undone. I have been j...
元スレも結構伸びてますね、読んでみるか
ここのとこの話を見てて、どんなビューの場合でも、String.Indexを受け取った時に、内部的に左側直近の、そのビューでの要素単位の合法な境界に畳み込まれるっていうのがいいと思いました
Avatar
norio_nomura 31-Jan-19 01:48 AM
要素ってunicodeScalar?
Avatar
omochimetaru 31-Jan-19 01:48 AM
string.unicodeScalars[index] の場合はunicode scalar
string[index]の場合はcharacter
string.utf8[index]はバイト位置(あ、この場合は不正なところになりえる string.utf16[index]は2バイト境界
ただ直近のCharacterまで巻き戻すのがまあまあ重そう
Avatar
norio_nomura 31-Jan-19 01:51 AM
Swift 4までのUTF8View.IndexUnicodeScalarの境界に合わせられていました。 @swift-4.2.4
func printUnicodeScalars<S: StringProtocol>(_ string: S) { print(string.unicodeScalars.map { "\\u{\(String($0.value, radix: 16))}" }.joined()) } // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" printUnicodeScalars(family) let utf8Index = family.utf8.index(before: family.utf8.endIndex) let utf8Before = String(family[..<utf8Index]) printUnicodeScalars(utf8Before) let utf8After = String(family[utf8Index...]) printUnicodeScalars(utf8After) printUnicodeScalars(utf8Before + utf8After) print(utf8After.utf8.count)
Avatar
swift42 BOT 31-Jan-19 01:51 AM
\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d} \u{1f466} \u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466} 4
Avatar
norio_nomura 31-Jan-19 01:51 AM
Swift 5ではUTF16View.IndexUnicodeScalarの境界に合わせられる様になった。
Avatar
omochimetaru 31-Jan-19 01:53 AM
内部表現ではない方のindexが、unicode scalar境界に畳み込まれる という意味では
一貫している?
Avatar
norio_nomura 31-Jan-19 01:55 AM
UnicodeScalar boundaries are: respected by: String.UTF8View.index(before:) on Swift 4 String.UTF16View.index(before:) on Swift 5 not respected by String.UTF16View.index(before:) on Swift 4 String.UTF8View.index(before:) on Swift 5
UTF-16からUTF-8へ切り替わった事で、挙動も入れ替わってる。
Avatar
norio_nomura 31-Jan-19 02:06 AM
内部表現ではない方のindexが、unicode scalar境界に畳み込まれる という意味では 一貫している?
そう言える。ランタイムの内部表現に依存してるかどうかまでは確かめてないですが。
Swift 5で試した限り、swift-corelibs-foundationだと内部表現をUTF-16にする方法は見つからず。Apple Platformだと一部のNSString APIを使うとUTF-16になる。
Avatar
omochimetaru 31-Jan-19 02:09 AM
ああ、そうすると実行時に変化もするのか・・
Avatar
norio_nomura 31-Jan-19 02:16 AM
以前試した時は、macOSでString.init(contentsOfFile:encoding:)を使うと内部表現がUTF-16になってた。
見分け方は、String.UTF8View.withContiguousStorageIfAvailable(_:)を使った時、渡したクロージャが呼ばれたら内部表現はUTF-8、呼ばれなかったらUTF-16
Avatar
norio_nomura 31-Jan-19 02:47 AM
Swift 5のString.UnicodeScalarsView.map(_:)でクラッシュ https://bugs.swift.org/browse/SR-9822 @swift-4.2.4 @swift-5.0.3 -frontend -repl
// https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" let utf8Index = family.utf8.index(before: family.utf8.endIndex) let utf8Before = String(family[..<utf8Index]) _ = utf8Before.unicodeScalars.map { $0 }
(edited)
Avatar
swift42 BOT 31-Jan-19 02:47 AM
// family : String = "👨‍👩‍👧‍👦" // utf8Index : String.UTF8View.Index = Swift.String.Index(_compoundOffset: 39, _utf8Buffer: Swift._ValidUTF8Buffer<Swift.UInt32>(_biasedBits: 2811404529), _graphemeStrideCache: 0) // utf8Before : String = "👨‍👩‍👧‍"
(edited)
Avatar
swift50 BOT 31-Jan-19 02:47 AM
exit status: 11 with stderr:
Stack dump: 0. Program arguments: swift -frontend -I /Libraries/.build/x86_64-unknown-linux/debug -L /Libraries/.build/x86_64-unknown-linux/debug -lLibraries -DDEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -repl 1. while processing REPL source: // https://emojipedia.org/family-man-woman-girl-boy/ let family = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" let utf8Index = family.utf8.index(before: family.utf8.endIndex) [0
(edited)
Avatar
norio_nomura 31-Jan-19 02:57 AM
ForumのType Safety of String IndicesについてのMichael_Ilsemanさんの返答を読んでると、UTF8View.index(before:)UTF16View.index(before:)は使ってはいけないモノだと言われている様に思えてくる。
Avatar
norio_nomura 31-Jan-19 03:19 AM
ランタイムの内部表現に依存してるかどうかまでは確かめてないですが。
依存してるぽい。
このコードをmacOSで実行すると、stringUTF16Backendを使うとtest()内でクラッシュする。
import Foundation #if !compiler(>=5) private extension String.UTF8View { func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> R? { return nil } } #endif extension String { var nativeEncoding: Encoding { return utf8.withContiguousStorageIfAvailable({$0}) != nil ? .utf8 : .utf16 } } func printUTF16<S: StringProtocol>(_ string: S, label: String) { print(label, string.utf16.map { "\\u{\(String($0, radix: 16))}" }.joined()) } func test(_ string: String) { let utf16Index = string.utf16.index(before: string.utf16.endIndex) let utf16Before = string[..<utf16Index] printUTF16(utf16Before, label: "before:") let utf16After = string[utf16Index...] printUTF16(utf16After, label: "after:") printUTF16(utf16Before + utf16After, label: "joined:") print(utf16After.utf8.count) print(utf16After.utf16.count) } // https://emojipedia.org/family-man-woman-girl-boy/ let string = "\u{1f468}\u{200d}\u{1f469}\u{200d}\u{1f467}\u{200d}\u{1f466}" print(string.nativeEncoding) test(string) let tempfileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(UUID().uuidString) try string.write(to: tempfileURL, atomically: true, encoding: .utf16) let stringUTF16Backend = try String(contentsOfFile: tempfileURL.path) print(stringUTF16Backend.nativeEncoding) test(stringUTF16Backend) defer { try! FileManager.default.removeItem(at: tempfileURL) }
(edited)
Avatar
norio_nomura 31-Jan-19 04:10 AM
- String.UTF8View, String.UTF16Viewを使ったString.Indexの操作は、UnicodeScalarsの境界に合わないIndexを作る場合がある。(仕様) - Swift 5はUnicodeScalarsの境界に合わないIndexを使ったRangeでSubstringを作ると、クラッシュする場合がある。(バグ) (edited)
そんな感じか。
Avatar
norio_nomura 31-Jan-19 06:03 AM
@rintaroさんの
https://bugs.swift.org/browse/SR-6161 これを思い出しました。
を読んで、試して、ようやく理解したぽい。 問題となるのはindex(before:)の挙動ではなく、String, UTF8View, UTF16Viewそれぞれのsubscriptがunicode scalarsの境界に合わないIndexを持つRangeをどう扱うか、が変わっている事なのね。
(edited)
Avatar
norio_nomura 31-Jan-19 06:22 AM
SR-6161の結果がSwift 4とSwift 5で変わってしまうのは、境界に合わないIndexが指すものはU+FFFDとして扱わなければいけないのだけど、境界に合う合わないの判定がUnicode Scalarを基に行われていないからな気がする。
Avatar
norio_nomura 04-Feb-19 10:46 PM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 04-Feb-19 10:46 PM
4.2.2-RELEASE
Avatar
nekonoki 05-Feb-19 09:43 AM
@swift-4.2.4
import Foundation [1, 2, 3] .map { ($0, $0) } .forEach { print("-") } [1, 2, 3] .map { ($0, $0) } .forEach { print($1) }
(edited)
Avatar
swift42 BOT 05-Feb-19 09:43 AM
- - - 1 2 3
stderr:
<stdin>:5:12: warning: expression of type '(Int, Int)' is unused .map { ($0, $0) } ^~~~~~~~
(edited)
Avatar
nekonoki 05-Feb-19 09:47 AM
expression of type '(Int, Int)' is unused このワーニングが RxSwift の map でも出てきて驚いた 😮subscribe で値を参照したら正しく警告が消えた)
Avatar
masakihori 06-Feb-19 07:03 AM
@swift-4.2.4 -Xfrontend -emit-sil
[1, 2, 3] .map { ($0, $0) } .forEach { print("-") }
Avatar
swift42 BOT 06-Feb-19 07:03 AM
sil_stage canonical import Builtin import Swift import SwiftShims // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = metatype $@thin Array<Int>.Type // user: %25 %3 = integer_literal $Builtin.Word, 3 // user: %5 // function_ref _allocateUninitializedArray<A>(_:) %4 = function_ref @$Ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 %5 = apply %4<Int>(%3) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // users: %9, %6, %8 %6 = tuple_extract %5 : $(Array<Int>, Builtin.RawPointer), 0 // users: %25, %7 retain_value %6 : $Array<Int> // id: %7 %8 = tuple_extract %5 : $(Array<Int>, Builtin.RawPointer), 1 // user: %10 release_value %5 : $(Array<Int>, Builtin.RawPointer) // id: %9 %10 = pointer_to_address %8 : $Builtin.RawPointer to [strict] $*Int // users: %13, %20, %15 %11 = integer_literal $Builtin.Int64, 1 // user: %12 %12 = struct $Int (%11 : $Builtin.Int64) // user: %13 store %12 to %10 : $*Int // id: %13 %14 = integer_literal $Builtin.Word, 1 // user: %15 %15 = index_addr %10 : $*Int, %14 : $Builtin.Word // user: %18 %16 = integer_literal $Builtin.Int64, 2 // user: %17 %17 = struct $Int (%16 : $Builtin.Int64) // user: %18 store %17 to %15 : $*Int // id: %18 %19 = integer_literal $Builtin.Word, 2 // user: %20 %20 = index_addr %10 : $*Int, %19 : $Builtin.Word // user: %23 %21 = integer_literal $Builtin.Int64, 3 // user: %22 %22 = struct $Int (%21 : $Builtin.Int64) // user: %23 store %22 to %20 : $*Int // id: %23 // function_ref specialized Array.init(arrayLiter
Avatar
masakihori 06-Feb-19 07:04 AM
map { ($0, $0) } が Array<Void> を返してると推論してる
僕には意味が分かりません
Avatar
omochimetaru 06-Feb-19 07:08 AM
どうなってるんだこれ
Avatar
t.ae 06-Feb-19 07:09 AM
forEachのクロージャが引数なしで()->Void扱いでmapの結果が[Void]と推論されているのでは? (edited)
Avatar
masakihori 06-Feb-19 07:10 AM
@swift-4.2.4
[1, 2, 3] .map { return ($0, $0) } .forEach { print("-") }
Avatar
swift42 BOT 06-Feb-19 07:10 AM
- - -
stderr:
<stdin>:3:18: warning: expression of type '(Int, Int)' is unused .map { return ($0, $0) } ^~~~~~~~
Avatar
masakihori 06-Feb-19 07:10 AM
明示的に return してもだめという
Avatar
omochimetaru 06-Feb-19 07:11 AM
forEach のクロージャの引数の型か。
Avatar
tarunon 06-Feb-19 07:11 AM
@swift-4.2.4
[1, 2, 3] .map { return ($0, $0) } .forEach { _ in print("-") }
Avatar
swift42 BOT 06-Feb-19 07:11 AM
- - -
Avatar
tarunon 06-Feb-19 07:11 AM
引数省略に明示が必要です
$0無し_無しはVoidになる
Avatar
omochimetaru 06-Feb-19 07:12 AM
Voidというか引数0個?
Avatar
masakihori 06-Feb-19 07:12 AM
分かるけどそこは forEach に _ in 付けろって言ってほしい
Avatar
omochimetaru 06-Feb-19 07:12 AM
[1, 2, 3] .map { ($0, $0) } .forEach { () in print("") }
こうなってるのか
(edited)
Avatar
t.ae 06-Feb-19 07:12 AM
[1, 2, 3] .map { a in return (a, a) } .forEach { print("-") }
これが通って
[1, 2, 3] .map { a -> (Int, Int) in return (a, a) } .forEach { print("-") }
これがだめなのが謎
Avatar
omochimetaru 06-Feb-19 07:13 AM
それは返り値の型を明示するからは
mapが(Int, Int)でforEachは () だから矛盾
Avatar
t.ae 06-Feb-19 07:13 AM
明示しない場合上のreturn で返してるのはどうなるんです?
Avatar
omochimetaru 06-Feb-19 07:14 AM
[1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
tarunon 06-Feb-19 07:14 AM
return ; ($0, $0) な解釈では
どうやったらそうなるんだって感じだけど
Avatar
t.ae 06-Feb-19 07:14 AM
ん?返り値Voidで返り値あっても通るのか
Avatar
omochimetaru 06-Feb-19 07:14 AM
func a(_ f: () -> Void) {} a { return 333 }
Avatar
t.ae 06-Feb-19 07:14 AM
タプルの場合のみとおる?
Avatar
tarunon 06-Feb-19 07:15 AM
@swift-4.2.4
var a: () -> Void = { return (1, 2) }
(edited)
Avatar
swift42 BOT 06-Feb-19 07:15 AM
stderr:
<stdin>:3:10: warning: expression of type '(Int, Int)' is unused return (1, 2) ^~~~~~
(edited)
Avatar
omochimetaru 06-Feb-19 07:15 AM
関数だとだめ
クロージャを書く時だけいける?
Avatar
t.ae 06-Feb-19 07:15 AM
カオスだ
Avatar
omochimetaru 06-Feb-19 07:15 AM
新発見か?
Avatar
tarunon 06-Feb-19 07:15 AM
クロージャだけ通る
Avatar
omochimetaru 06-Feb-19 07:16 AM
知らなかった
Avatar
tarunon 06-Feb-19 07:16 AM
クロージャはreturn省略可能でfuncは省略不可、その辺りに何かありそう
Avatar
omochimetaru 06-Feb-19 07:16 AM
@swift-4.2.4
let a: () -> Int = { return 3 } let b: () -> Void = a
(edited)
Avatar
swift42 BOT 06-Feb-19 07:16 AM
exit status: 1 with stderr:
<stdin>:3:21: error: cannot convert value of type '() -> Int' to specified type '() -> Void' let b: () -> Void = a ^
(edited)
Avatar
omochimetaru 06-Feb-19 07:17 AM
type checkerのバグな気がしてきた
クロージャの返り値の評価のときだけ void への暗黙アップキャストが存在してる?
Avatar
tarunon 06-Feb-19 07:18 AM
expression of type '(Int, Int)' is unused
だから暗黙変換系ではない
Avatar
omochimetaru 06-Feb-19 07:18 AM
いや、それは前段のmap側だから 後段のクロージャが
[1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
tarunon 06-Feb-19 07:19 AM
foEachのクロージャによってmapの返り血はVoidに推論されている
Avatar
omochimetaru 06-Feb-19 07:19 AM
@swift-4.2.4
[1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
swift42 BOT 06-Feb-19 07:19 AM
- - -
stderr:
<stdin>:3:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, a) } ^~~~~~
Avatar
tarunon 06-Feb-19 07:19 AM
そのうえで、return (a,a)が謎解釈で return ; (a, a)になってるんだと思うよ (edited)
@swift-4.2.4
func a() -> Void { return; (1, 1) }
Avatar
swift42 BOT 06-Feb-19 07:20 AM
stderr:
<stdin>:2:28: warning: expression of type '(Int, Int)' is unused func a() -> Void { return; (1, 1) } ^~~~~~ <stdin>:2:28: warning: code after 'return' will never be executed func a() -> Void { return; (1, 1) } ^
Avatar
omochimetaru 06-Feb-19 07:20 AM
いやそれだと
うむ
returnの後ろに死んだ文があることになるはずだから
Avatar
tarunon 06-Feb-19 07:20 AM
エラーメッセージ同じぽいし
Avatar
omochimetaru 06-Feb-19 07:20 AM
will never be executedが出てるから違う
Avatar
tarunon 06-Feb-19 07:20 AM
片方だけでてる
@swift-4.2.4
func fatal() -> Int { fatalError() } [1, 2, 3] .map { a -> Void in return (a, fatal()) } .forEach { print("-") }
Avatar
swift42 BOT 06-Feb-19 07:21 AM
exit status: 4 with stderr:
<stdin>:4:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, fatal()) } ^~~~~~~~~~~~ Fatal error: : file <stdin>, line 2 Current stack trace: 0 libswiftCore.so 0x00007fce9010bfa0 _swift_stdlib_reportFatalErrorInFile + 215 1 libswiftCore.so 0x00007fce8fe645c1 <unavailable> + 1504705 2 libswiftCore.so 0x00007fce900a10c2 <unavailable> + 3850434 3 libswiftCore.so 0x00007fce8fe63d0a <unavailable> + 1502474 4 libswiftCore.so 0x00007fce900a0f5c <unavailable> + 3850076 5 libswiftCore.so 0x00007fce8fe63d0a <unavailable> + 1502474 6 libswiftCore.so 0x00007fce8fffda28 <unavailable> + 3181096 7 libswiftCore.so 0x00007fce8fe635a9 <unavailable> + 1500585 12 libswiftCore.so 0x00007fce8fe27640 Collection.map<A>(_:) + 527 14 swift 0x0000000001043efe <unavailable> + 12861182 15 swift 0x0000000001048022 <unavailable> + 12877858 16 swift 0x00000000004f8b42 <unavailable> + 1018690 17 swift 0x00000000004df0bb <unavailable> + 913595 18 swift 0x00000000004da3f0 <unavailable> + 893936 19 swift 0x000000000048a348 <unavailable> + 566088 20 libc.so.6 0x00007fce92ab0740 __libc_start_main + 240 21 swift 0x0000000000488009 <unavailable> + 557065 #0 0x000000000410ac94 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410ac94) #1 0x0000000004108b22 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b22) #2 0x000000000410ae42 SignalHandler(int) (/usr/bin/swift+0x410ae42) #3 0x00007fce94386390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x0
Avatar
tarunon 06-Feb-19 07:22 AM
おー
実行はされてる
Avatar
omochimetaru 06-Feb-19 07:25 AM
なるほどw
とりあえずbugs行きっぽいな
@swift-nightly @swift-5.0.3
[1, 2, 3] .map { a -> Void in return (a, a) } .forEach { print("-") }
Avatar
swift50 BOT 06-Feb-19 07:26 AM
- - -
stderr:
<stdin>:3:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, a) } ^~~~~~
Avatar
swiftNightly BOT 06-Feb-19 07:26 AM
- - -
stderr:
<stdin>:3:32: warning: expression of type '(Int, Int)' is unused .map { a -> Void in return (a, a) } ^~~~~~
Avatar
omochimetaru 06-Feb-19 07:27 AM
@swift-4.2.4
let a = { () -> Void in return 333 }
Avatar
swift42 BOT 06-Feb-19 07:27 AM
stderr:
<stdin>:3:12: warning: integer literal is unused return 333 ^~~
Avatar
omochimetaru 06-Feb-19 07:27 AM
シンプルにこういうことだよね
Avatar
tarunon 06-Feb-19 07:27 AM
そう
Avatar
omochimetaru 06-Feb-19 07:28 AM
もしこれがそもそもコンパイルエラーになっていれば
[1, 2, 3] .map { return ($0, $0) } .forEach { print("-") }
これはコンパイルエラーになるから
それでよかった
Avatar
tarunon 06-Feb-19 07:28 AM
どっちにエラーを出すかは結構難しい
.forEach { print("-") } こいつはこの行だけで引数Voidが決定的だから
Avatar
omochimetaru 06-Feb-19 07:29 AM
.map { } も決定的でしょ、 返り値 (A, A) (edited)
Avatar
tarunon 06-Feb-19 07:29 AM
まあ今はバグってるからそっちにエラーが出るのはわかる
Avatar
nekonoki 06-Feb-19 08:55 AM
なるほど 😮
Avatar
norio_nomura 06-Feb-19 09:54 AM
面白い
Avatar
norio_nomura 06-Feb-19 12:35 PM
@swift-4.2.4
let a = { () -> Void in return 333 }
Avatar
swift42 BOT 06-Feb-19 12:35 PM
stderr:
<stdin>:2:12: warning: integer literal is unused return 333 ^~~
Avatar
norio_nomura 06-Feb-19 12:36 PM
ボットのエラーメッセージに含まれる行番号が1つズレていたのを修正しました。
Avatar
rintaro 06-Feb-19 05:47 PM
- single expression closure ではクロージャの返値が Void の時でも、非Void のexpressionを書ける - { ... in return <expr> } は single expression closure と解釈される という事実が重なって起きてる不幸ですね (edited)
let _ : () -> Void = { return "test" }
が通るの自体はもはや仕様なので、エラー診断のバグという扱いになると思います。
Avatar
omochimetaru 07-Feb-19 12:45 AM
なるほど、コンパイラはそういう気持ちなのか
swift 1
Avatar
norio_nomura 01-Mar-19 04:04 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 01-Mar-19 04:04 AM
4.2.3-RELEASE
Avatar
nekonoki 05-Mar-19 05:14 AM
@swift-4.2.4
import Foundation class Entity<Id: Hashable, Props> { let id: Id let data: Props init(id: Id, data: Props) { self.id = id self.data = data } } class User: Entity<User.Id, User.Props> { struct Id: Hashable { } struct Props { var name: String } } let user = User(id: .init(), data: .init(name: "user_name")) print(user, user.data.name)
Avatar
swift42 BOT 05-Mar-19 05:14 AM
main.User user_name
Avatar
kateinoigakukun 10-Mar-19 05:32 AM
@swift-nightly
func defaultValue<T>() -> T { fatalError() } struct S<T> { let value1: T = defaultValue() let value2: Int } func main() { _ = S<Int>(value2: 2) }
(edited)
Avatar
swiftNightly BOT 10-Mar-19 05:32 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/SILGen/SILGenConstructor.cpp:146: void emitImplicitValueConstructor(swift::Lowering::SILGenFunction &, swift::ConstructorDecl *): Assertion `fieldTy->isEqual(field->getParentInitializer()->getType()) && "Checked by sema"' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=
(edited)
Avatar
tarunon 12-Mar-19 09:00 AM
@swift-4.2.4
class Some { lazy var thing = 1 } class Some2: Some { override lazy var thing = 2 } print(Some2().thing)
Cannot (Cannotとは言っていない)
😂 1
Avatar
swift42 BOT 12-Mar-19 09:00 AM
2
stderr:
<stdin>:6:23: warning: cannot override with a stored property 'thing' override lazy var thing = 2 ^ <stdin>:2:14: note: attempt to override property here lazy var thing = 1 ^
Avatar
tarunon 13-Mar-19 05:24 AM
↑なんですが、要はコンパイラが作るlazyに値を渡すためのfunctionはオーバーライド可能だったってことですかね
結構便利なんですがこれw
Avatar
omochimetaru 13-Mar-19 05:29 AM
stored propertyはそもそもオーバライド可能だから (edited)
継承先の方のlazyが特殊なところ?
Avatar
nekonoki 13-Mar-19 10:05 AM
@swift-5.0.3 @swift-4.2.4
import Foundation protocol Target { } protocol Foo { associatedtype Bar: Target } class TargetBase<X>: Target {} class Impl<X, TargetType>: Foo where TargetType: TargetBase<X> { typealias Bar = TargetType }
(edited)
Avatar
swift50 BOT 13-Mar-19 10:06 AM
no output (edited)
Avatar
swift42 BOT 13-Mar-19 10:06 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/AST/Type.cpp:3215: swift::Type swift::TypeBase::getSuperclassForDecl(const swift::ClassDecl *): Assertion `nominalDecl && "expected nominal type here"' failed. #0 0x000000000410acb4 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x410acb4) #1 0x0000000004108b42 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x4108b42) #2 0x000000000410ae62 SignalHandler(int) (/usr/bin/swift+0x410ae62) #3 0x00007fefce714390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390) #4 0x00007fefcce53428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428) #5 0x00007fefcce5502a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a) #6 0x00007fefcce4bbd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7) #7 0x00007fefcce4bc82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) #8 0x00000000017ff77c swift::TypeBase::getSuperclassForDecl(swift::ClassDecl const*) (/usr/bin/swift+0x17ff77c) #9 0x00000000017e357a swift::ProtocolConformance::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const (/usr/bin/swift+0x17e357a) #10 0x00000000013c9607 swift::ConformanceChecker::ensureRequirementsAreSatisfied(bool)::GatherConformancesListener::satisfiedConformance(swift::Type, swift::Type, swift::ProtocolConformanceRef) (/usr/bin/swift+0x13c9607) #11 0x00000000013a7582 swift::TypeChecker::checkGenericArguments(swift::DeclContext*, swift::SourceLoc, swift::SourceLoc, swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, llvm::ArrayRef<swift::Requirement>, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::Prot
Avatar
norio_nomura 17-Mar-19 11:55 PM
@swift-nightly
let a = "abc" let b = "cde" dump(b.difference(from: a))
(edited)
Avatar
swiftNightly BOT 17-Mar-19 11:55 PM
▿ Swift.CollectionDifference<Swift.Character> ▿ insertions: 2 elements ▿ Swift.CollectionDifference<Swift.Character>.Change.insert ▿ insert: (3 elements) - offset: 1 - element: "d" - associatedWith: nil ▿ Swift.CollectionDifference<Swift.Character>.Change.insert ▿ insert: (3 elements) - offset: 2 - element: "e" - associatedWith: nil ▿ removals: 2 elements ▿ Swift.CollectionDifference<Swift.Character>.Change.remove ▿ remove: (3 elements) - offset: 0 - element: "a" - associatedWith: nil ▿ Swift.CollectionDifference<Swift.Character>.Change.remove ▿ remove: (3 elements) - offset: 1 - element: "b" - associatedWith: nil
(edited)
Avatar
norio_nomura 19-Mar-19 12:24 PM
@swift-5.0.3 @swift-nightly
struct S { func f() -> Self { return self } }
Avatar
swiftNightly BOT 19-Mar-19 12:24 PM
no output
Avatar
swift50 BOT 19-Mar-19 12:24 PM
exit status: 1 with stderr:
<stdin>:2:17: error: 'Self' is only available in a protocol or as the result of a method in a class; did you mean 'S'? func f() -> Self { return self } ^~~~ S
Avatar
omochimetaru 19-Mar-19 12:24 PM
あれ、まだ入ってない?
マージされてたような
Avatar
norio_nomura 19-Mar-19 12:24 PM
5.0には入ってないね。
Avatar
omochimetaru 19-Mar-19 12:25 PM
あ、nightlyは通ったのか。
お~ これほしかったので密かに喜んでいた
Avatar
Kishikawa Katsumi 19-Mar-19 12:29 PM
Self書けるのいいですね。
Avatar
kateinoigakukun 21-Mar-19 10:10 AM
@swift-5.0.3
class Base { let val: String = "string" } class Sub: Base {} let object = Sub() print(object[keyPath: \Base.val]) // "string" print(object[keyPath: \Sub.val]) // Crash!
Avatar
swift50 BOT 21-Mar-19 10:10 AM
string string
Avatar
kateinoigakukun 21-Mar-19 10:10 AM
@swift-4.2.4
class Base { let val: String = "string" } class Sub: Base {} let object = Sub() print(object[keyPath: \Base.val]) // "string" print(object[keyPath: \Sub.val]) // Crash!
Avatar
swift42 BOT 21-Mar-19 10:10 AM
string string
Avatar
kateinoigakukun 21-Mar-19 10:10 AM
@swift-nightly
class Base { let val: String = "string" } class Sub: Base {} let object = Sub() print(object[keyPath: \Base.val]) // "string" print(object[keyPath: \Sub.val]) // Crash!
Avatar
swiftNightly BOT 21-Mar-19 10:10 AM
string string
Avatar
kateinoigakukun 23-Mar-19 01:51 AM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3
protocol P { associatedtype X } struct S<X>: P { }
(edited)
Avatar
swift50 BOT 23-Mar-19 01:51 AM
no output (edited)
Avatar
swift42 BOT 23-Mar-19 01:51 AM
no output (edited)
Avatar
swift40 BOT 23-Mar-19 01:52 AM
exit status: 1 with stderr:
<stdin>:6:8: error: type 'S<X>' does not conform to protocol 'P' struct S<X>: P { ^ <stdin>:2:20: note: protocol requires nested type 'X'; do you want to add it? associatedtype X ^
(edited)
Avatar
swift41 BOT 23-Mar-19 01:52 AM
no output
Avatar
kateinoigakukun 23-Mar-19 01:52 AM
型パラと同名assoctypeの束縛できるようになってる!!!!
うれしい!
Avatar
kateinoigakukun 23-Mar-19 07:32 AM
@swift-nightly
import Foundation let kp = \UUID.uuid let writable = kp as! WritableKeyPath<UUID, uuid_t> var uuid = UUID() print(uuid) var newUUID: uuid_t = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) uuid[keyPath: writable] = newUUID print(uuid)
(edited)
Avatar
swiftNightly BOT 23-Mar-19 07:32 AM
A1717B4D-EE97-460A-B7C6-1149A2E2561A 00000000-0000-0000-0000-000000000000
(edited)
Avatar
omochimetaru 25-Mar-19 03:33 AM
@swift-4.2.4 @swift-5.0.3
protocol ProtoA {} protocol ProtoB { associatedtype T : ProtoA var stuff: Int { get } } extension ProtoB { var stuff: Int { return 0 } } class Foo<X: ProtoA> : ProtoB { typealias T = X }
Avatar
swift42 BOT 25-Mar-19 03:33 AM
no output
Avatar
swift50 BOT 25-Mar-19 03:33 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift/lib/AST/ProtocolConformance.cpp:77: swift::ProtocolDecl *swift::ProtocolConformanceRef::getRequirement() const: Assertion `!isInvalid()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main
Avatar
omochimetaru 25-Mar-19 03:34 AM
@swift-4.2.4 @swift-5.0.3 @swift-nightly
protocol ProtoA {} protocol ProtoB { associatedtype T : ProtoA func stuff() -> Int } extension ProtoB { func stuff() -> Int { return 0 } } class Foo<X: ProtoA> : ProtoB { typealias T = X }
Avatar
swift42 BOT 25-Mar-19 03:34 AM
no output
Avatar
swift50 BOT 25-Mar-19 03:34 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift/lib/AST/ProtocolConformance.cpp:77: swift::ProtocolDecl *swift::ProtocolConformanceRef::getRequirement() const: Assertion `!isInvalid()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main
Avatar
swiftNightly BOT 25-Mar-19 03:34 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/AST/ProtocolConformance.cpp:77: swift::ProtocolDecl *swift::ProtocolConformanceRef::getRequirement() const: Assertion `!isInvalid()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOZlib/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOZlib.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio-zlib-support/module.modulemap -module-name main -lL
Avatar
norio_nomura 25-Mar-19 03:36 AM
ぬう、ログのアップローダとして使ってた https://ptpb.pw が無くなってるな…
Avatar
omochimetaru 25-Mar-19 03:36 AM
無くなってるはすごいw
跡形もない・・
Avatar
t.ae 25-Mar-19 03:40 AM
TL;DR: coin miners are assholes, ruining this great service for everyone Due to continued write and egress abuse, ptpb.pw is now ~permanently shut down. The current pb implementation has always bee...
Avatar
norio_nomura 25-Mar-19 03:41 AM
ちょうどそれ読んでた。
https://file.io へ戻しました。 (edited)
file.io は一度開いたurlは無くなるんだよね。(最初に作った時は知らなかった)
ゆる募) アップロードしたファイルをブラウザ内で見られるアップローダの情報。 (edited)
Avatar
koher 26-Mar-19 04:07 AM
@swift-5.0.3
let hello: Result<String, Error> = .success("Hello Swift 5!") print(try! hello.get())
(edited)
Avatar
swift50 BOT 26-Mar-19 04:07 AM
Hello Swift 5!
(edited)
Avatar
norio_nomura 27-Mar-19 12:42 PM
@swift-nightly
let array = Array<Int>(unsafeUninitializedCapacity: 10) { for i in 0..<5 { $0[i] = i } $1 = 5 } dump(array)
👍 1
Avatar
swiftNightly BOT 27-Mar-19 12:42 PM
▿ 5 elements - 0 - 1 - 2 - 3 - 4
Avatar
nekonoki 29-Mar-19 05:07 AM
@swift-4.2.4 @swift-5.0.3
import Foundation class _Foo { } protocol BarType { typealias BaseFoo = _Foo } class Bar: BarType { class Foo: BaseFoo {} } class FooImpl: Bar.Foo { } print(FooImpl())
(edited)
Avatar
swift50 BOT 29-Mar-19 05:07 AM
exit status: 1 with stderr:
<unknown>:0: error: 'super' members cannot be referenced in a root class
(edited)
Avatar
swift42 BOT 29-Mar-19 05:07 AM
main.FooImpl
(edited)
Avatar
norio_nomura 30-Mar-19 06:48 AM
@swift-4.2.4
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift42 BOT 30-Mar-19 06:48 AM
4.2.4-RELEASE
Avatar
norio_nomura 01-Apr-19 02:28 AM
しばらくSwift50, SwiftNightly, SwiftTensorFlowはオフラインになりがちとなります。 メンテナンス終わりました。 (edited)
Avatar
omochimetaru 02-Apr-19 07:42 AM
@swift-5.0.3
protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : C<T>, U : P {}
(edited)
Avatar
swift50 BOT 02-Apr-19 07:42 AM
exit status: 1 with stderr:
<stdin>:7:46: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:36: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:38: error: type 'T' does not conform to protocol 'Q' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^
(edited)
Avatar
omochimetaru 02-Apr-19 07:42 AM
@swift-nightly
protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : C<T>, U : P {}
(edited)
Avatar
swiftNightly BOT 02-Apr-19 07:42 AM
exit status: 1 with stderr:
<stdin>:7:46: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:36: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:38: error: type 'T' does not conform to protocol 'Q' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^
(edited)
Avatar
omochimetaru 02-Apr-19 07:43 AM
@swift-4.2.4
protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : C<T>, U : P {}
Avatar
swift42 BOT 02-Apr-19 07:43 AM
stderr:
<stdin>:7:46: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^ <stdin>:7:36: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : C<T>, U : P {} ^
Avatar
omochimetaru 02-Apr-19 09:17 AM
@swift-4.2.4
protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : P, U : C<T> {}
Avatar
swift42 BOT 02-Apr-19 09:17 AM
stderr:
<stdin>:6:36: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^ <stdin>:6:43: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^
Avatar
omochimetaru 02-Apr-19 09:17 AM
@swift-nightly
protocol Q {} protocol P { associatedtype T : Q } class C<T> : P where T : Q {} func foo<U, T>(_: U, _: T) where U : P, U : C<T> {}
Avatar
swiftNightly BOT 02-Apr-19 09:17 AM
stderr:
<stdin>:6:36: warning: redundant conformance constraint 'U': 'P' func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^ <stdin>:6:43: note: conformance constraint 'U': 'P' implied here func foo<U, T>(_: U, _: T) where U : P, U : C<T> {} ^
Avatar
omochimetaru 03-Apr-19 04:20 AM
@swift-5.0.3
let fn: @pseudogeneric () -> () = {}
Avatar
swift50 BOT 03-Apr-19 04:20 AM
no output
Avatar
omochimetaru 03-Apr-19 04:20 AM
The Swift compiler accepts this code: let fn: @pseudogeneric () -> () = {} (This is a bug; @pseudogeneric is only meant for SIL mode, but due to an oversight it’s accepted and ignored during normal parsing too)
Avatar
kateinoigakukun 03-Apr-19 11:29 AM
@swift-5.0.3 @swift-nightly @swift-4.2.4
public protocol P1 { associatedtype X } struct A { } protocol P2: P1 { associatedtype X = A func foo() } public struct B {} extension B: P2 { }
(edited)
Avatar
swift50 BOT 03-Apr-19 11:29 AM
exit status: 134 with stderr:
<stdin>:15:1: error: type 'B' does not conform to protocol 'P2' extension B: P2 { ^ Unhandled Decl kind UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift/lib/AST/DeclContext.cpp:893! Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries /usr/bin/swift[0x462b784] /usr/bin/swift[0x4629550] /usr/bin/swift[0x462b932] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fdd299dc390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fdd2811b428] /lib/x86_64-linux-gnu/libc.so.6(ab
(edited)
Avatar
swift42 BOT 03-Apr-19 11:53 AM
exit status: 1 with stderr:
<stdin>:15:1: error: type 'B' does not conform to protocol 'P2' extension B: P2 { ^ <stdin>:10:10: note: protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub? func foo() ^
Avatar
swiftNightly BOT 03-Apr-19 11:53 AM
exit status: 1 with stderr:
<stdin>:15:1: error: type 'B' does not conform to protocol 'P2' extension B: P2 { ^ <stdin>:15:1: error: type alias 'X' must be declared public because it matches a requirement in public protocol 'P1' extension B: P2 { ^ main.B:2:22: note: mark the type alias as 'public' to satisfy the requirement public typealias X = main.A ^ <stdin>:10:10: note: protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub? func foo() ^
Avatar
norio_nomura 03-Apr-19 02:10 PM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-nightly
if #available(macOS 10.14, *) { print("macOS", terminator: " ") } if #available(iOS 12.3, *) { print("iOS", terminator: " ") } if #available(tvOS 12.3, *) { print("tvOS", terminator: " ") } if #available(watchOS 5.2, *) { print("watchOS", terminator: " ") }
Avatar
swift42 BOT 03-Apr-19 02:10 PM
macOS iOS tvOS watchOS
Avatar
swiftNightly BOT 03-Apr-19 02:10 PM
macOS iOS tvOS watchOS
Avatar
swift50 BOT 03-Apr-19 02:10 PM
macOS iOS tvOS watchOS
Avatar
swift40 BOT 03-Apr-19 02:10 PM
macOS iOS tvOS watchOS
Avatar
swift41 BOT 03-Apr-19 02:10 PM
macOS iOS tvOS watchOS
Avatar
omochimetaru 04-Apr-19 02:26 AM
@swift-nightly
let a = [1,2,3] let b = [2] let diff = a.difference(from: b) dump(diff)
Avatar
swiftNightly BOT 04-Apr-19 02:26 AM
▿ Swift.CollectionDifference<Swift.Int> ▿ insertions: 2 elements ▿ Swift.CollectionDifference<Swift.Int>.Change.insert ▿ insert: (3 elements) - offset: 0 - element: 1 - associatedWith: nil ▿ Swift.CollectionDifference<Swift.Int>.Change.insert ▿ insert: (3 elements) - offset: 2 - element: 3 - associatedWith: nil - removals: 0 elements
Avatar
happiness9721 11-Apr-19 02:03 AM
@swift-nightly
let a = [1,2,3] let b = [2] let diff = a.difference(from: b) print(diff)
Avatar
swiftNightly BOT 11-Apr-19 02:03 AM
CollectionDifference<Int>(insertions: [Swift.CollectionDifference<Swift.Int>.Change.insert(offset: 0, element: 1, associatedWith: nil), Swift.CollectionDifference<Swift.Int>.Change.insert(offset: 2, element: 3, associatedWith: nil)], removals: [])
Avatar
omochimetaru 17-Apr-19 01:47 AM
@swift-nightly
class C { @inlinable func f() {} // error }
Avatar
swiftNightly BOT 17-Apr-19 01:47 AM
no output
Avatar
d_date 17-Apr-19 09:46 AM
@swift-4.2.4
import UIKit protocol Component: UIView { associatedtype Model func activate(with model: Model) func deactivate() } class ImageComponent: UIImageView, Component { typealias Model = UIImage func activate(with model: ImageComponent.Model) { image = model } func deactivate() { image = nil } }
Avatar
swift42 BOT 17-Apr-19 09:46 AM
exit status: 1 with stderr:
<stdin>:1:8: error: no such module 'UIKit' import UIKit ^
Avatar
d_date 17-Apr-19 09:46 AM
そりゃそうだ
Avatar
omochimetaru 17-Apr-19 12:15 PM
macサーバーほしいよね
でも安くやる方法がない (edited)
Avatar
norio_nomura 17-Apr-19 02:37 PM
機能的にはAzure PipelinesのmacOS Agentが使えるのでは?とか考えたけど、TOSに反するかどうか未確認…>macサーバー
Avatar
Kishikawa Katsumi 17-Apr-19 02:50 PM
Playground程度なら遊んでる家のMacでできるけど、AppKitはともかくUIKitはうまいこと実行するのが難しそうだな。
Avatar
omochimetaru 17-Apr-19 05:32 PM
確かにPlaygroundは実行できてもコマンドラインバイナリとして実効する手段が無いですね。 ライブラリにしてシミュレーター上でテストケースを実行するとかはできるけど
Avatar
norio_nomura 17-Apr-19 11:29 PM
$ pbpaste import UIKit protocol Component: UIView { associatedtype Model func activate(with model: Model) func deactivate() } class ImageComponent: UIImageView, Component { typealias Model = UIImage func activate(with model: ImageComponent.Model) { image = model } func deactivate() { image = nil } $ pbpaste|swiftc -sdk $(xcrun -show-sdk-path -sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - -v Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5) Target: x86_64-apple-ios12.2-simulator /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file - -target x86_64-apple-ios12.2-simulator -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -color-diagnostics -module-name main -o /var/folders/kt/2mwy9b_56_7993x190pl_1fh0000gn/T/--eec0d7.o /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld /var/folders/kt/2mwy9b_56_7993x190pl_1fh0000gn/T/--eec0d7.o /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/lib/darwin/libclang_rt.ios.a -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.2.sdk -lobjc -lSystem -arch x86_64 -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -ios_simulator_version_min 12.2.0 -no_objc_category_merging -o main $ ./main dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit Referenced from: /Users/norio/github/docker-swift/./main Reason: image not found [1] 91007 abort ./main
swiftc -sdk $(xcrun -show-sdk-path -sdk iphonesimulator) -target x86_64-apple-ios12.2-simulatorでビルド出来る。
DYLDの環境変数を調整すれば、実行も出来るかな?
Avatar
omochimetaru 17-Apr-19 11:31 PM
おお!
-Xlinkerでrpath埋め込むのでもいけそう
Avatar
norio_nomura 17-Apr-19 11:32 PM
ふむ。
Avatar
omochimetaru 17-Apr-19 11:32 PM
これもできた
$ swiftc -emit-library m.swift $ swiftc -L . -lm -I . a.swift -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx $ ./a
↑こんなふんいき
Avatar
norio_nomura 17-Apr-19 11:43 PM
@rpathを使わずにリンクされてるから、それは効かないですね。
$ otool -L main main: /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1) /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 61000.0.0) @rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftCoreImage.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftMetal.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftQuartzCore.dylib (compatibility version 1.0.0, current version 1001.0.82) @rpath/libswiftUIKit.dylib (compatibility version 1.0.0, current version 1001.0.82)
Avatar
omochimetaru 17-Apr-19 11:44 PM
UIKitの部分とかはOSに入ってる想定だから、そうなるのか。なるほど。
Avatar
norio_nomura 18-Apr-19 12:00 AM
install_name_toolUIKitのパスを変えたら、@rpath/libswiftCore.dylibをロードできないと言われた。
$ install_name_tool -change /System/Library/Frameworks/UIKit.framework/UIKit $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/Frameworks/UIKit.framework/UIKit main $ ./main dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /Users/norio/github/docker-swift/./main Reason: image not found [1] 95202 abort ./main
(edited)
で、rpathを設定したらUIKitにリンクされてるDocumentManagerをロードできないと言われ、ここで「実行時の環境を変えないとダメだ。」となりinstall_name_toolを使う方法は終了。
$ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - -Xlinker -rpath -Xlinker $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift $ install_name_tool -change /System/Library/Frameworks/UIKit.framework/UIKit $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/Frameworks/UIKit.framework/UIKit main $ ./main dyld: Library not loaded: /System/Library/PrivateFrameworks/DocumentManager.framework/DocumentManager Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/Frameworks/UIKit.framework/UIKit Reason: image not found [1] 95440 abort ./main
Avatar
omochimetaru 18-Apr-19 12:04 AM
バイナリをシミュレーターコンテナ?のなかで起動しないとだめそうですね
Avatar
norio_nomura 18-Apr-19 12:06 AM
simctlはアプリケーションバンドルを起動するコマンドしかないから、chroot的な仕組みを使うしか無さげ。
Avatar
omochimetaru 18-Apr-19 12:11 AM
playground/iosとかはどうやってるんだろうなあ
Avatar
norio_nomura 18-Apr-19 12:14 AM
playgroundはsimulatorが動いてる。
Avatar
omochimetaru 18-Apr-19 12:14 AM
そのシミュレーターに対して、任意のコードを送り込める所の仕組みが知りたい
Avatar
norio_nomura 18-Apr-19 12:19 AM
アプリケーションバンドルを作成してるんじゃないかな。
Avatar
omochimetaru 18-Apr-19 12:19 AM
最近のxcodeで1行ずつ実行できるようになったから
あれはREPLな気がします 昔のやつはアプリにしてIOは頑張ってるのかな
Avatar
norio_nomura 18-Apr-19 12:28 AM
アクティビティモニタで見るとやはりアプリケーションバンドルを作成して実行してる様に見えます。 /Users/norio/Library/Developer/XCPGDevices/8B3C76D2-C6BA-49FA-A03F-76AA29054FF3/data/Containers/Bundle/Application/269B83DA-876D-4C78-8197-D055CD0E0B5C/PlayNow-20190418-86360-2.app/PlayNow-20190418
Avatar
norio_nomura 18-Apr-19 12:35 AM
ああ、DYLD操作で実行出来た。
$ DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks DYLD_FALLBACK_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks DYLD_LIBRARY_PATH= ./main
Avatar
omochimetaru 18-Apr-19 12:36 AM
おお!
Avatar
norio_nomura 18-Apr-19 12:38 AM
rpath設定は必要。
$ pbpaste import UIKit print("UIKit") $ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - -Xlinker -rpath -Xlinker $(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift $ DYLD_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks DYLD_FALLBACK_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_FALLBACK_FRAMEWORK_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks DYLD_LIBRARY_PATH= ./main UIKit
まあiPhoneのUIを実際に使うコードは動かないけど、UIKitをリンクして動かすことは出来た。
Avatar
omochimetaru 18-Apr-19 12:43 AM
フルパスで参照してるフレームワークも 差し替え効くんですね DYRD_ROOT_PATHがそれか?
Avatar
norio_nomura 18-Apr-19 12:43 AM
DYLD_*環境変数は、playgroundが実行してるアプリケーションに渡されてたものを全部記述しました。 (edited)
Avatar
omochimetaru 18-Apr-19 12:44 AM
なるほど!どうやって読み取ったんですか?
Avatar
norio_nomura 18-Apr-19 12:45 AM
アクティビティモニタでプロセス名を調べps axe|grep プロセス名ですね。
該当プロセスとgrepのプロセスの情報が出ます。 (edited)
Avatar
omochimetaru 18-Apr-19 12:48 AM
psのe知りませんでした なるほどーー
Avatar
norio_nomura 18-Apr-19 01:14 AM
DYLD_FALLBACK_LIBRARY_PATHusr/lib/swiftの分も追加すれば、rpath指定無しでいける。
$ ROOT_PATH=$(xcrun --show-sdk-platform-path --sdk iphoneos)/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_LIBRARY_PATH= \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main
(edited)
Avatar
omochimetaru 18-Apr-19 01:21 AM
なるほど
Avatar
norio_nomura 18-Apr-19 01:36 AM
DYLD_LIBRARY_PATH= は無くても良さげ。simctljq.simruntimeの場所を取得する方法に書き換えると
$ ROOT_PATH=$(xcrun simctl list -j runtimes ios|jq -r '.runtimes[-1]|.bundlePath')/Contents/Resources/RuntimeRoot && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main
が一番シンプルな記述かな。
(edited)
まとめると
$ pbpaste import UIKit protocol Component: UIView { associatedtype Model func activate(with model: Model) func deactivate() } class ImageComponent: UIImageView, Component { typealias Model = UIImage func activate(with model: ImageComponent.Model) { image = model } func deactivate() { image = nil } } print("UIKit") $ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios12.2-simulator - $ ROOT_PATH=$(xcrun simctl list -j runtimes ios|jq -r '.runtimes[-1]|.bundlePath')/Contents/Resources/RuntimeRoot && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main UIKit
Avatar
omochimetaru 18-Apr-19 01:41 AM
xcrun simctlってJSONで出してくれるオプションあるんですね。
Avatar
norio_nomura 18-Apr-19 01:41 AM
うん。
-target x86_64-apple-ios12.2-simulatorが決め打ちになっちゃうのだけ気持ちが悪いな。
Avatar
omochimetaru 18-Apr-19 01:42 AM
もしbotだとしたら swift-5.0-iOS12.2
みたいな名前になりそう。
Avatar
norio_nomura 18-Apr-19 01:47 AM
あれ?swiftcへ渡す-targetって任意なの?
Avatar
Kishikawa Katsumi 18-Apr-19 01:48 AM
無くても実行できました?
Avatar
norio_nomura 18-Apr-19 01:49 AM
あいや、-target x86_64-apple-ios12までは短く出来たけど、無くすまでは無理だった。
Avatar
Kishikawa Katsumi 18-Apr-19 01:50 AM
12無くせません?
Avatar
norio_nomura 18-Apr-19 01:51 AM
無くすと、-Xlinker-ios_simulator_version_minを指定する必要が出てきそうです。
$ pbpaste|swiftc -sdk $(xcrun --show-sdk-path --sdk iphonesimulator) -target x86_64-apple-ios - -v <unknown>:0: error: Swift requires a minimum deployment target of iOS 7
Avatar
Kishikawa Katsumi 18-Apr-19 01:52 AM
なるほど。なくすより10あたりを指定しておくのが良さそうかな。
Avatar
norio_nomura 18-Apr-19 01:52 AM
ですね。
Avatar
Kishikawa Katsumi 18-Apr-19 01:52 AM
そこに数字が出てくるのはしょうがないので。
Avatar
norio_nomura 18-Apr-19 02:01 AM
あえてバージョンを取得するなら
$ jq -r .Version $(xcrun --show-sdk-path --sdk iphonesimulator)/SDKSettings.json 12.2
辺りかな。
(edited)
Avatar
norio_nomura 18-Apr-19 02:20 AM
このiOS Simulator向けにビルドしてCLIで実行って、WWDC19以降は簡単になりそうだよね。
Avatar
omochimetaru 18-Apr-19 02:20 AM
マジパン関係ですか?
Avatar
norio_nomura 18-Apr-19 02:22 AM
既に/System/iOSSupport/System/Library/Frameworks/UIKit.frameworkとかMojaveにあるし。
Avatar
omochimetaru 18-Apr-19 02:23 AM
ほんとだw
Avatar
norio_nomura 18-Apr-19 02:25 AM
先の手法でビルドしたものに /System/iOSSupport を渡すとこんな感じ。
$ ROOT_PATH=/System/iOSSupport && \ DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks \ DYLD_FALLBACK_LIBRARY_PATH=$ROOT_PATH/usr/lib:$ROOT_PATH/usr/lib/swift \ DYLD_ROOT_PATH=$ROOT_PATH \ ./main dyld: mach-o, but built for simulator (not macOS) [1] 7681 abort DYLD_FALLBACK_FRAMEWORK_PATH=$ROOT_PATH/System/Library/Frameworks = = ./main
$ otool -l /System/iOSSupport/System/Library/Frameworks/UIKit.framework/UIKit … Load command 7 cmd LC_BUILD_VERSION cmdsize 32 platform iosmac sdk 10.14 minos 12.0 ntools 1 tool ld version 450.1 … $ otool -l /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework/UIKit … Load command 7 cmd LC_BUILD_VERSION cmdsize 32 platform iossimulator sdk 12.2 minos 12.2 ntools 1 tool ld version 450.1
platform iosmac
Avatar
omochimetaru 18-Apr-19 02:32 AM
iosmac
Avatar
norio_nomura 18-Apr-19 02:41 AM
このiOS Simulator向けにビルドしてCLIで実行
正確には、macOSでUIKitを使う、か。
Avatar
norio_nomura 18-Apr-19 03:20 AM
swift-5.1-DEVELOPMENT-SNAPSHOT-2019-04-16-aが出た。 @swift-5.1.5 -version
Avatar
swift51 BOT 18-Apr-19 03:20 AM
Swift version 5.0-dev (LLVM f961e3dd74, Swift 85a776dac0) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 18-Apr-19 03:24 AM
@swift-5.1.5
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift51 BOT 18-Apr-19 03:24 AM
5.1-DEVELOPMENT-SNAPSHOT-2019-04-16-a
Avatar
norio_nomura 19-Apr-19 11:42 PM
@swift-5.0.3
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift50 BOT 19-Apr-19 11:42 PM
5.0.1-RELEASE
Avatar
koher 20-Apr-19 02:55 PM
@swift-nightly
protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal())
(edited)
Avatar
swiftNightly BOT 20-Apr-19 02:55 PM
exit status: 1 with stderr:
<stdin>:3:26: error: consecutive statements on a line must be separated by ';' func makeAnimal() -> some Animal { ^ ; <stdin>:3:22: error: use of undeclared type 'some' func makeAnimal() -> some Animal { ^~~~ <stdin>:3:27: error: 'Animal' cannot be constructed because it has no accessible initializers func makeAnimal() -> some Animal { ^
Avatar
koher 20-Apr-19 02:57 PM
マージされてるけどまだか。 https://github.com/apple/swift/pull/22072
A continuation of #21137. This branch adds &quot;proper&quot; resilience support. Opaque types can now enter the SIL type system, and will be able to be represented at runtime with opaque a...
Avatar
omochimetaru 25-Apr-19 05:37 AM
@swift-5.1.5
protocol P {} extension Int : P {} func f() -> some P { return 3 }
(edited)
Avatar
swift51 BOT 25-Apr-19 05:37 AM
exit status: 1 with stderr:
<stdin>:3:17: error: consecutive statements on a line must be separated by ';' func f() -> some P { return 3 } ^ ; <stdin>:3:13: error: use of undeclared type 'some' func f() -> some P { return 3 } ^~~~ <stdin>:3:18: error: 'P' cannot be constructed because it has no accessible initializers func f() -> some P { return 3 } ^
Avatar
koher 25-Apr-19 07:05 AM
@swift-nightly
protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal())
Avatar
swiftNightly BOT 25-Apr-19 07:05 AM
exit status: 1 with stderr:
<stdin>:3:26: error: consecutive statements on a line must be separated by ';' func makeAnimal() -> some Animal { ^ ; <stdin>:3:22: error: use of undeclared type 'some' func makeAnimal() -> some Animal { ^~~~ <stdin>:3:27: error: 'Animal' cannot be constructed because it has no accessible initializers func makeAnimal() -> some Animal { ^
Avatar
koher 25-Apr-19 07:07 AM
見るの間違えた。まだ4/16から更新されてなかった。 https://swift.org/download/#snapshots
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
Avatar
omochimetaru 25-Apr-19 07:30 AM
マージされたのが4.19か
実際snapshot全然出てないな
Avatar
shunkun 26-Apr-19 06:43 AM
おじゃまします🙇 @swift-5.0.3
print("👶".unicodeScalars.first?.properties.isEmoji)
Avatar
swift50 BOT 26-Apr-19 06:43 AM
exit status: 1 with stderr:
<stdin>:1:36: error: value of type 'Unicode.Scalar.Properties' has no member 'isEmoji' print("👶".unicodeScalars.first?.properties.isEmoji)
🤔 1
Avatar
omochimetaru 26-Apr-19 06:48 AM
@swift-nightly
"👶".unicodeScalars.first!.properties.isEmoji
(edited)
Avatar
swiftNightly BOT 26-Apr-19 06:48 AM
exit status: 1 with stderr:
<stdin>:1:41: error: value of type 'Unicode.Scalar.Properties' has no member 'isEmoji' "👶".unicodeScalars.first!.properties.isEmoji
(edited)
Avatar
omochimetaru 26-Apr-19 06:49 AM
@swift-nightly
let scalars: [Unicode.Scalar] = ["😎", "$", "0"] for s in scalars { print(s, "-->", s.isEmoji) } // 😎 --> true // $ --> false // 0 --> true
Avatar
swiftNightly BOT 26-Apr-19 06:49 AM
exit status: 1 with stderr:
<stdin>:3:23: error: value of type 'Unicode.Scalar' has no member 'isEmoji' print(s, "-->", s.isEmoji) ~ ^~~~~~~
Avatar
omochimetaru 26-Apr-19 06:49 AM
@swift-nightly
let scalars: [Unicode.Scalar] = ["😎", "$", "0"] scalars.forEach { dump($0.properties) }
(edited)
Avatar
swiftNightly BOT 26-Apr-19 06:50 AM
▿ Swift.Unicode.Scalar.Properties - _scalar: "\u{0001F60E}" ▿ Swift.Unicode.Scalar.Properties - _scalar: "$" ▿ Swift.Unicode.Scalar.Properties - _scalar: "0"
(edited)
Avatar
omochimetaru 26-Apr-19 06:50 AM
よくわからん。
Avatar
shunkun 26-Apr-19 06:50 AM
ですね...
Avatar
d_date 26-Apr-19 06:51 AM
@swift-5.0.3
import Foundation print("👶".unicodeScalars.first?.properties)
(edited)
Avatar
swift50 BOT 26-Apr-19 06:51 AM
Optional(Swift.Unicode.Scalar.Properties(_scalar: "\u{0001F476}"))
stderr:
<stdin>:2:7: warning: expression implicitly coerced from 'Unicode.Scalar.Properties?' to 'Any' print("👶".unicodeScalars.first?.properties) <stdin>:2:36: note: provide a default value to avoid this warning print("👶".unicodeScalars.first?.properties) <stdin>:2:36: note: force-unwrap the value to avoid this warning print("👶".unicodeScalars.first?.properties) <stdin>:2:36: note: explicitly cast to 'Any' with 'as Any' to silence this warning print("👶".unicodeScalars.first?.properties)
(edited)
Avatar
omochimetaru 26-Apr-19 06:52 AM
macはできた。
Avatar
d_date 26-Apr-19 06:53 AM
Playgroundでもできるんだよねぇ
Avatar
shunkun 26-Apr-19 06:53 AM
ここはできた
Avatar
d_date 26-Apr-19 06:55 AM
これじゃね? @available(OSX 10.12.2, iOS 10.2, tvOS 10.1, watchOS 3.1.1, *) public var isEmoji: Bool { get }
Avatar
omochimetaru 26-Apr-19 06:56 AM
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) // FIXME: These properties were introduced in ICU 57, but Ubuntu 16.04 comes // with ICU 55 so the values won't be correct there. Exclude them on // non-Darwin platforms for now; bundling ICU with the toolchain would resolve // this and other inconsistencies (https://bugs.swift.org/browse/SR-6076). /// A Boolean value indicating whether the scalar has an emoji /// presentation, whether or not it is the default. 略 @available(macOS 10.12.2, iOS 10.2, tvOS 10.1, watchOS 3.1.1, *) public var isEmoji: Bool { return _hasBinaryProperty(__swift_stdlib_UCHAR_EMOJI) }
👌 1
🙇 1
ICU57で入ったけどUbuntu16.04のICUは55だから対応してないってさ。
Avatar
d_date 26-Apr-19 06:57 AM
:naruhodo:
Avatar
norio_nomura 27-Apr-19 12:21 AM
5.1の新しいスナップショットきたけど、someが入るのは次かな。 @swift-5.1.5
protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal())
(edited)
😩 1
Avatar
swift51 BOT 27-Apr-19 12:21 AM
exit status: 1 with stderr:
<stdin>:3:26: error: consecutive statements on a line must be separated by ';' func makeAnimal() -> some Animal { ^ ; <stdin>:3:22: error: use of undeclared type 'some' func makeAnimal() -> some Animal { ^~~~ <stdin>:3:27: error: 'Animal' cannot be constructed because it has no accessible initializers func makeAnimal() -> some Animal { ^
(edited)
Avatar
koher 27-Apr-19 01:50 AM
5.1 に入るんですっけ?
Avatar
tarunon 27-Apr-19 01:50 AM
はやい。次のわいわいでもう使えるかな
Avatar
koher 27-Apr-19 01:50 AM
Trunk Development (master) の方は April 16 のままですね。
@tarunon スナップショットは出てないですがマージはされてるんで自分でビルドすれば使えるんじゃないかと思います。 Bot の話の意かもですが・・・。
Avatar
tarunon 27-Apr-19 01:53 AM
Botの意でした
👌 1
Avatar
norio_nomura 27-Apr-19 03:16 AM
Avatar
koher 27-Apr-19 08:04 AM
おお、じゃあ5.1に入るんですね!
Avatar
tarunon 27-Apr-19 05:21 PM
https://github.com/ReactiveX/RxSwift/issues/1921#issuecomment-487286983 RxSwiftのswift5のIF決めるスレでORTの話題出てきたけど、「出てきてからね」の流れになったw 認知はされてるから、もしかしたらRxSwiftにも入るかもですね
Hey @kzaher &amp; others - Since RxSwift 5 is around the corner, I took the liberty of making a list of PRs/Issues that were delayed for RxSwift 5. The goal here is to see if: Any of them are e...
後方互換性キツそうだなという気はする
Avatar
norio_nomura 01-May-19 11:45 PM
@swift-nightly @swift-5.1.5
protocol Animal {} struct Cat: Animal {} func makeAnimal() -> some Animal { return Cat() } print(makeAnimal())
(edited)
Avatar
swiftNightly BOT 01-May-19 11:45 PM
Cat()
(edited)
🎉 3
Avatar
swift51 BOT 02-May-19 11:34 AM
Cat()
Avatar
omochimetaru 07-May-19 04:22 AM
@swift-nightly
protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return 0 } func f() -> some P2 { return 0 }
Avatar
swiftNightly BOT 07-May-19 04:22 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:112: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. Swift version 5.0-dev (LLVM 082dec2e22, Swift f5ba89d372) 2. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48f7534] /usr/bin/swift[0x48f5150] /usr/bin/swift[0x48f7958] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fc231aaf390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fc2301ee428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fc2301f002a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7fc2301e6bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7fc2301e6c82] /usr/bin/swift[0xdf2d10] /usr/bin/swift[0x893a8c] /usr/bin/swift[0x89433d] /usr/bin/swift[0x89a2ec] /usr/bin/swift[0x89b334] /usr/bin/swift[0x89b93b] /usr/bin/swift[0x508302] /usr/bin/swift[0x504b9f] /usr/bin/swift[0x4a002d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fc2301d9830] /usr/bin/swift[0x49fb89]
Avatar
omochimetaru 07-May-19 04:28 AM
@swift-5.1.5
protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return 0 } func f() -> some P2 { return 0 }
Avatar
swift51 BOT 07-May-19 04:28 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:108: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48e9374] /usr/bin/swift[0x48e6f90] /usr/bin/swift[0x48e9798] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fcf15036390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fcf13775428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fcf1377702a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7fcf1376dbd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7fcf1376dc82] /usr/bin/swift[0xdda2b0] /usr/bin/swift[0x89124c] /usr/bin/swift[0x891afd] /usr/bin/swift[0x897d7c] /usr/bin/swift[0x898da4] /usr/bin/swift[0x8993ab] /usr/bin/swift[0x5081da] /usr/bin/swift[0x504a8f] /usr/bin/swift[0x4a000d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fcf13760830] /usr/bin/swift[0x49fb89]
Avatar
omochimetaru 07-May-19 04:29 AM
@swift-nightly
protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return Int(0) } func f() -> some P2 { return Int(0) }
Avatar
swiftNightly BOT 07-May-19 04:29 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:112: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. Swift version 5.0-dev (LLVM 082dec2e22, Swift f5ba89d372) 2. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48f7534] /usr/bin/swift[0x48f5150] /usr/bin/swift[0x48f7958] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7ff7202b0390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7ff71e9ef428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7ff71e9f102a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7ff71e9e7bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7ff71e9e7c82] /usr/bin/swift[0xdf2d10] /usr/bin/swift[0x893a8c] /usr/bin/swift[0x89433d] /usr/bin/swift[0x89a2ec] /usr/bin/swift[0x89b334] /usr/bin/swift[0x89b93b] /usr/bin/swift[0x508302] /usr/bin/swift[0x504b9f] /usr/bin/swift[0x4a002d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ff71e9da830] /usr/bin/swift[0x49fb89]
Avatar
omochimetaru 07-May-19 04:30 AM
あれ〜 このオーバーロードsemaでエラーになるテストが既にマージされてるんだけどな。
Avatar
norio_nomura 07-May-19 06:05 AM
This is necessary because: func foo() -&gt; some P func foo() -&gt; some P theoretically defines two distinct return types, but there&#39;d be no way to disambiguate them. Disallow ove...
Avatar
norio_nomura 07-May-19 06:14 AM
なんか微妙に違うな。
Avatar
omochimetaru 07-May-19 06:14 AM
はい
テストケースのここ
func redeclaration() -> some P { return 0 } // expected-note{{previously declared}} func redeclaration() -> some P { return 0 } // expected-error{{redeclaration}} func redeclaration() -> some Q { return 0 }
(edited)
some Pとsome Qが並んでるので(エラーにはなってないみたいだけど)少なくともコンパイラクラッシュはしないはず
Avatar
norio_nomura 07-May-19 10:22 AM
ふむ @swift-5.1.5 -frontend -typecheck -verify
protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return Int(0) } func f() -> some P2 { return Int(0) }
Avatar
swift51 BOT 07-May-19 10:22 AM
no output
Avatar
tarunon 07-May-19 10:23 AM
👀
Avatar
omochimetaru 07-May-19 10:23 AM
あ、そうか、テストコードはIRGenまでやってないのか。
Avatar
tarunon 07-May-19 10:23 AM
@swift-5.1.5
protocol P1 {} protocol P2 {} extension Int : P1 {} extension Int : P2 {} func f() -> some P1 { return Int(0) } func f() -> some P2 { return Int(0) } func r<T: P1>(_ a: T) { print(a) } r(f())
(edited)
Avatar
swift51 BOT 07-May-19 10:24 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-16_04/swift/lib/SIL/SILFunctionBuilder.cpp:108: swift::SILFunction *swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter): Assertion `fn->getLoweredFunctionType() == constantType' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. While emitting SIL for 'f()' (at <stdin>:6:1) /usr/bin/swift[0x48e9374] /usr/bin/swift[0x48e6f90] /usr/bin/swift[0x48e9798] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f0ffb06b390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f0ff97aa428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f0ff97ac02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f0ff97a2bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f0ff97a2c82] /usr/bin/swift[0xdda2b0] /usr/bin/swift[0x89124c] /usr/bin/swift[0x891afd] /usr/bin/swift[0x897d7c] /usr/bin/swift[0x898da4] /usr/bin/swift[0x8993ab] /usr/bin/swift[0x5081da] /usr/bin/swift[0x504a8f] /usr/bin/swift[0x4a000d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f0ff9795830] /usr/bin/swift[0x49fb89]
Avatar
tarunon 07-May-19 10:24 AM
型が解ってもクラッシュするのか。
一瞬いけるんじゃないかと期待してしまった
Avatar
omochimetaru 07-May-19 10:24 AM
mangling結果が同じになるんだよね
それで後段のIRGenでぶっ壊れる
Avatar
tarunon 07-May-19 10:25 AM
なるほど
Avatar
omochimetaru 07-May-19 10:25 AM
前見たときはそうだった。
Avatar
nanasi 15-May-19 01:24 AM
@swift-5.0.3 @swift-nightly
import Foundation let data = Data([1, 2, 3]) print(data.range(of: Data([1, 2, 3])) ?? []) print(data.firstRange(of: Data([1, 2, 3])) ?? [])
(edited)
Avatar
swiftNightly BOT 15-May-19 01:24 AM
0..<3 []
(edited)
Avatar
swift50 BOT 15-May-19 01:24 AM
0..<3 []
(edited)
Avatar
nanasi 15-May-19 01:25 AM
@swift-5.0.3 @swift-nightly
import Foundation let data = Data([1, 2, 3, 2, 1]) print(data.range(of: Data([1]), options: .backwards) ?? []) print(data.lastRange(of: Data([1])) ?? [])
(edited)
Avatar
swift50 BOT 15-May-19 01:25 AM
4..<5 0..<1
(edited)
Avatar
swiftNightly BOT 15-May-19 01:25 AM
4..<5 0..<1
(edited)
Avatar
nanasi 15-May-19 01:27 AM
@swift-5.0.3 @swift-nightly
import Foundation let data = Data([1, 2, 3]) print(data.range(of: Data([1]), options: .backwards, in: data.startIndex..<data.endIndex) ?? []) print(data.lastRange(of: Data([1]), in: data.startIndex..<data.endIndex) ?? [])
(edited)
Avatar
swiftNightly BOT 15-May-19 01:27 AM
exit status: 4 with stderr:
Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -module-name main 1. Swift version 5.0-dev (LLVM 082dec2e22, Swift 87e1efd1a2) /usr/bin/swift[0x48fde14] /usr/bin/swift[0x48fba30] /usr/bin/swift[0x48fe238] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f02906e8390] /usr/lib/swift/linux/libFoundation.so($s10Foundation4DataV15_RepresentationOys5UInt8VSicig+0x1b3)[0x7f028930b133]
(edited)
Avatar
swift50 BOT 15-May-19 01:27 AM
exit status: 4 with stderr:
Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries /usr/bin/swift[0x4626bd4] /usr/bin/swift[0x46249a0] /usr/bin/swift[0x4626d82] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f14d1559390] /usr/lib/swift/linux/libFoundation.so($s10Foundation4DataV15_RepresentationOys5UInt8VSicig+0x1b3)[0x7f14c9cc7203]
(edited)
Avatar
nanasi 15-May-19 01:30 AM
firstRange/lastRange 周りがバグい
Avatar
omochimetaru 15-May-19 02:27 AM
なんだこれ。
@swift-5.1.5
import Foundation let data = Data([1, 2, 3]) let tests = [Data([1]), Data([1, 2]), Data([1, 2, 3])] for test in tests { let range = data.firstRange(of: test) print("\(range)") }
Avatar
swift51 BOT 15-May-19 02:30 AM
Optional(Range(0..<1)) Optional(Range(0..<1)) nil
stderr:
<stdin>:8:14: warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit? print("\(range)") ^~~~~ <stdin>:8:14: note: use 'String(describing:)' to silence this warning print("\(range)") ^~~~~ String(describing: ) <stdin>:8:14: note: provide a default value to avoid this warning print("\(range)") ^~~~~ ?? <#default value#>
Avatar
nanasi 15-May-19 04:33 AM
@swift-5.1.5
import Foundation let data = Data([1, 2, 3]) let tests = [Data([1]), Data([1, 2]), Data([1, 2, 3])] for test in tests { let range = (data as NSData).firstRange(of: test) print("\(range)") }
(edited)
Avatar
swift51 BOT 15-May-19 04:33 AM
Optional(Range(0..<1)) Optional(Range(0..<2)) Optional(Range(0..<3))
stderr:
<stdin>:8:14: warning: string interpolation produces a debug description for an optional value; did you mean to make this explicit? print("\(range)") ^~~~~ <stdin>:8:14: note: use 'String(describing:)' to silence this warning print("\(range)") ^~~~~ String(describing: ) <stdin>:8:14: note: provide a default value to avoid this warning print("\(range)") ^~~~~ ?? <#default value#>
(edited)
Avatar
nanasi 15-May-19 04:37 AM
DataProtocolのデフォルト実装が正しい実装になっていない 例えば↓など https://github.com/apple/swift-corelibs-foundation/blob/8043670b9d991d45ca72cfadc3806c68e9e16a05/Foundation/DataProtocol.swift#L82-L84
The Foundation Project, providing core utilities, internationalization, and OS independence - apple/swift-corelibs-foundation
😂 5
Avatar
omochimetaru 15-May-19 04:45 AM
これはww
Avatar
lovee 15-May-19 06:24 AM
いつから last最後 だと錯覚していたwww
Avatar
hironytic 16-May-19 02:05 AM
残念だ。いったんレビューの指摘を受けて直っているのに、PRをout of dateにして別のPRで作り直されたときにfirstに先祖返りしてしまってる 😭 https://github.com/apple/swift-corelibs-foundation/pull/1813#discussion_r243387179
This brings Data in sync with the overlay changes for the new inline revamp.
Avatar
omochimetaru 16-May-19 03:56 AM
マージ前に指摘はされていたのか〜
Avatar
ikesyo 25-May-19 10:34 PM
DataProtocol.lastRange(of:) の件、apple/swiftの(つまりDarwin用の)swift-5.0-branchだけ正しい状態だったので、まずapple/swiftのmasterに修正のPR出してみました https://github.com/apple/swift/pull/25065 (edited)
DataProtocol.lastRange(of:) is correct in swift-5.0-branch, but not in master and swift-5.1-branch. The changes are from #21292 (d7fcb87).
🙏 1
これが通ればswift-5.1-branchと、foundationのmasterと5.0-branchにも修正出す流れで。
Avatar
omochimetaru 25-May-19 10:35 PM
おお、ありがとうございます
Avatar
norio_nomura 26-May-19 03:21 AM
@swift-nightly -frontend -repl
import Foundation :print_decl URLSession import FoundationNetworking
Avatar
swiftNightly BOT 26-May-19 03:21 AM
@available(*, unavailable, message: "This type has moved to the FoundationNetworking module. Import that module to use it.") typealias URLSession = AnyObject
stderr:
<REPL Input>:1:8: error: no such module 'FoundationNetworking' import FoundationNetworking ^
Avatar
kateinoigakukun 27-May-19 01:59 PM
@swift-nightly @swift-5.1.5 @swift-5.0.3 @swift-4.2.4
indirect enum A { case case1 case case2(A, B) case case3(A, A, B) } indirect enum B { case case4(B) case case5 case case6 } func foo(_ a: A) { switch a { case .case2: break } }
Avatar
swift51 BOT 27-May-19 01:59 PM
exit status: 1 with stderr:
<stdin>:13:5: error: switch must be exhaustive switch a { ^ <stdin>:13:5: note: add missing case: '.case1' switch a { ^ <stdin>:13:5: note: add missing case: '.case3(_, _, _)' switch a { ^
Avatar
swift50 BOT 27-May-19 01:59 PM
no output
Avatar
swift42 BOT 27-May-19 01:59 PM
no output
Avatar
swiftNightly BOT 27-May-19 01:59 PM
exit status: 1 with stderr:
<stdin>:13:5: error: switch must be exhaustive switch a { ^ <stdin>:13:5: note: add missing case: '.case1' switch a { ^ <stdin>:13:5: note: add missing case: '.case3(_, _, _)' switch a { ^
Avatar
kateinoigakukun 27-May-19 02:00 PM
exhaustiveのチェックを壊してしまった
5.0は壊れてるけど5.0.1では治ってるのか (edited)
Avatar
ikesyo 30-May-19 03:05 PM
@swift-nightly @swift-5.1.5 @swift-5.0.3
import Foundation public protocol NMBComparable { func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult } extension NSNumber: NMBComparable { public func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult { return compare(otherObject as! NSNumber) } } func take<T: Comparable>(_ a: T, _ b: T) {} func take<T: NMBComparable>(_ a: T, _ b: T) {} take(1, 2) take(NSNumber(value: 1), NSNumber(value: 2)) take(1, NSNumber(value: 2)) take(NSNumber(value: 1), 2)
(edited)
Avatar
swiftNightly BOT 30-May-19 03:05 PM
exit status: 1 with stderr:
<stdin>:17:1: error: ambiguous use of 'take' take(NSNumber(value: 1), NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:18:1: error: ambiguous use of 'take' take(1, NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:19:1: error: ambiguous use of 'take' take(NSNumber(value: 1), 2) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^
(edited)
Avatar
swift51 BOT 30-May-19 03:05 PM
exit status: 1 with stderr:
<stdin>:17:1: error: ambiguous use of 'take' take(NSNumber(value: 1), NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:18:1: error: ambiguous use of 'take' take(1, NSNumber(value: 2)) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^ <stdin>:19:1: error: ambiguous use of 'take' take(NSNumber(value: 1), 2) ^ <stdin>:13:6: note: found this candidate func take<T: Comparable>(_ a: T, _ b: T) {} ^ <stdin>:14:6: note: found this candidate func take<T: NMBComparable>(_ a: T, _ b: T) {} ^
(edited)
Avatar
swift50 BOT 30-May-19 03:05 PM
no output (edited)
Avatar
ikesyo 30-May-19 03:12 PM
@swift-nightly @swift-5.1.5 @swift-5.0.3
import Foundation func take<T: Comparable>(_ a: T, _ b: T) {} take(NSNumber(value: 1), NSNumber(value: 2))
Avatar
swiftNightly BOT 30-May-19 03:12 PM
no output
Avatar
swift50 BOT 30-May-19 03:12 PM
exit status: 1 with stderr:
<stdin>:3:6: error: argument type 'NSNumber' does not conform to expected type 'Comparable' take(NSNumber(value: 1), NSNumber(value: 2)) ^
Avatar
swift51 BOT 30-May-19 03:12 PM
no output
Avatar
ikesyo 30-May-19 03:15 PM
master, Swift 5.1で、なぜかLinuxでNSNumberがComparableとして認識されている?
DarwinでのNSNumber
Implement the parts that can be implemented and annotate the rest with diagnostics. Add a partially source-compatible version of init(keyPath:ascending:) that works with Comparable values. A li...
Implement the parts that can be implemented and annotate the rest with diagnostics. Add a partially source-compatible version of init(keyPath:ascending:) that works with Comparable values. A li...
Avatar
norio_nomura 01-Jun-19 09:42 AM
@swift-nightly
@ _propertyWrapper enum Lazy<Value> { case uninitialized(() -> Value) case initialized(Value) init(initialValue: @autoclosure @escaping () -> Value) { self = .uninitialized(initialValue) } var value: Value { mutating get { switch self { case .uninitialized(let initializer): let value = initializer() self = .initialized(value) return value case .initialized(let value): return value } } set { self = .initialized(newValue) } } } @Lazy var foo = 1738
Avatar
swiftNightly BOT 01-Jun-19 09:42 AM
no output
Avatar
ikesyo 08-Jun-19 04:05 AM
@swift-5.1.5 -frontend -c -enable-experimental-static-assert
func isOne(_ x: Int) -> Bool { return x == 1 } func test_assertionSuccess() { #assert(isOne(1)) #assert(isOne(1), "1 is not 1") } func test_assertionFailure() { #assert(isOne(2)) // expected-error{{assertion failed}} #assert(isOne(2), "2 is not 1") // expected-error{{2 is not 1}} }
Avatar
swift51 BOT 08-Jun-19 04:05 AM
exit status: 1 with stderr:
<stdin>:11:3: error: assertion failed #assert(isOne(2)) // expected-error{{assertion failed}} ^ <stdin>:12:3: error: 2 is not 1 #assert(isOne(2), "2 is not 1") // expected-error{{2 is not 1}} ^
Avatar
tarunon 08-Jun-19 04:20 AM
便利だ
Avatar
omochimetaru 09-Jun-19 04:21 AM
お、マージされたか!
これパッチのころから追いかけていて、次の勉強会で紹介しようと思ってた
Avatar
ikesyo 09-Jun-19 10:46 AM
Constant Evaluatorで検索するとたくさんPR出てきます https://github.com/apple/swift/pulls?utf8=%E2%9C%93&q=is%3Apr+constant+evaluator
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
これってSILの最適化パスの一つとして実行されてる?という理解でよいのかな
Avatar
omochimetaru 10-Jun-19 12:57 AM
そうです、SILのパスになってる
🙌 1
Avatar
norio_nomura 14-Jun-19 11:37 PM
@swift-5.1.5
import FoundationNetworking
Avatar
swift51 BOT 14-Jun-19 11:37 PM
no output
Avatar
takasek 27-Jun-19 11:08 AM
@swift-5.1.5
func f(g: () -> Int) -> String { "\(g())" } print(f { 42 })
Avatar
swift51 BOT 27-Jun-19 11:08 AM
42
Avatar
takasek 27-Jun-19 11:08 AM
@tarunon
Avatar
tarunon 27-Jun-19 11:08 AM
いけるのか
引数のとこが自由度高すぎるように見えるので
例えば環境から値注入するとか出来ちゃうよなーと思った次第です
注入してる側でコンパイルエラーするのかな
Avatar
takasek 27-Jun-19 11:11 AM
そうそう、できちゃうのでgも @compilerEvaluable にしなきゃいけなくて、 そうすると依存性切り離して使いたい関数を @compilerEvaluable にするような運用はできないってことになるので、 普段使いできそうにないなーと
Avatar
tarunon 27-Jun-19 11:12 AM
今の所暗黙的に計算してるのかなと思いますが…フーム
Avatar
Avatar
tarunon 27-Jun-19 11:27 AM
@takasek printじゃなくて#assertですね
Avatar
takasek 27-Jun-19 11:28 AM
あーいや、もとからできない例として書いたつもりだった
@swift-5.1.5
#assert(1 < 2)
Avatar
swift51 BOT 27-Jun-19 11:29 AM
exit status: 1 with stderr:
<stdin>:1:1: error: #assert is an experimental feature that is currently disabled #assert(1 < 2) ^
Avatar
takasek 27-Jun-19 11:31 AM
@swift-5.1.5 -frontend -c -enable-experimental-static-assert
#assert(1 < 2)
Avatar
swift51 BOT 27-Jun-19 11:31 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-16_04/llvm/lib/Support/raw_ostream.cpp:735: uint64_t llvm::raw_fd_ostream::seek(uint64_t): Assertion `SupportsSeeking && "Stream does not support seeking!"' failed. Stack dump: 0. Program arguments: swift -frontend -c -enable-experimental-static-assert - swift[0x4938c34] swift[0x4936850] swift[0x4939058] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f7c86339390] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f7c84a78428] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f7c84a7a02a] /lib/x86_64-linux-gnu/libc.so.6(+0x2dbd7)[0x7f7c84a70bd7] /lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f7c84a70c82] swift[0x49196b0] swift[0x4919701] swift[0x4657dda] swift[0x4651a63] swift[0x45ed347] swift[0x1eaf048] swift[0x47b2e45] swift[0x47b3423] swift[0x5847c1] swift[0x50a4e4] swift[0x5058cf] swift[0x4a022d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7c84a63830] swift[0x49fda9]
Avatar
takasek 27-Jun-19 11:31 AM
おや
Avatar
omochimetaru 27-Jun-19 11:31 AM
なぜころたし
Avatar
koher 02-Jul-19 04:19 AM
@swift-5.0.3
class Animal { func foo() -> Int? { return nil } } class Cat: Animal { override func foo() -> Int { return 42 } } let animal: Animal = Cat() print(animal.foo()!)
Avatar
swift50 BOT 02-Jul-19 04:19 AM
42
Avatar
omochimetaru 02-Jul-19 07:27 AM
@swift-5.1.5
class Animal { func foo() -> Int? { return nil } } class Cat: Animal { override func foo() -> Int { return 42 } override func foo() -> Int? { return nil } }
Avatar
swift51 BOT 02-Jul-19 07:27 AM
exit status: 1 with stderr:
<stdin>:9:19: error: 'foo()' has already been overridden override func foo() -> Int? { return nil } ^ <stdin>:8:19: note: 'foo()' previously overridden here override func foo() -> Int { return 42 } ^
Avatar
omochimetaru 02-Jul-19 07:28 AM
ちゃんとしてる
Avatar
norio_nomura 08-Jul-19 01:19 PM
Swift 5.1 で OpenCombine https://github.com/broadwaylamb/OpenCombine をインポート出来るようにしました。 @swift-5.1.5
import OpenCombine let publisher = Just(28) _ = publisher .map { number in return "Antoine's age is \(number)" } .sink { (value) in print(value) }
(edited)
Open-source implementation of Apple's Combine framework for processing values over time. - broadwaylamb/OpenCombine
Avatar
swift51 BOT 08-Jul-19 01:19 PM
Antoine's age is 28
(edited)
Avatar
omochimetaru 09-Jul-19 01:16 AM
OpenCombineなるほど
そういうのがあればCombineによせても、Linux対応問題は一応解決するな、挙動同じなら・・・
Avatar
t.ae 09-Jul-19 01:33 AM
完全に挙動同じライブラリがある場合Combineのメリットって何になるんでしょう。 アプリサイズが小さくなるくらいしか思いつかないですが。
Avatar
omochimetaru 09-Jul-19 01:33 AM
iOSでもこっちを使うってこと?
Avatar
t.ae 09-Jul-19 01:33 AM
iOS開発の場合はそうですね。 コマンドラインツールとかubuntuでも動くのの場合のことを考えてました。
Avatar
omochimetaru 09-Jul-19 01:34 AM
FoundationとかUIkitの関連APIを全部2重で生やさないといけないけど
実装されているならApple版は要らないね
どっちかというと、すでにapple版があるのにOSS版の実装が完全に整うかどうかって点で
実現しない気がする。
てか挙動同じならなおさらどっちでもいいので作る必要がない
あ、でもソース付きデバッグできるとかあるかも。
ストリーム系は特にややこいし。
Avatar
t.ae 09-Jul-19 01:37 AM
やはりapple系ではCombineでしょうね。 それになれた開発者がlinux開発に行くときに使うかも?ってくらいになりそうでしょうか。
Avatar
omochimetaru 09-Jul-19 01:38 AM
うん。
あ〜
SSSで非同期処理の基盤で使うってのはあるかなあ?
Promiseの代わり。
Rx.Single型相当があるんだったらありな気がする
Avatar
t.ae 09-Jul-19 01:40 AM
既存フレームワークはswift-nioベースで割り込む余地無さそうですけどね。 (edited)
Avatar
omochimetaru 09-Jul-19 01:40 AM
nioはネットワークレイヤーであって非同期基盤ではなくない?Promiseも提供してんだっけ。
Avatar
t.ae 09-Jul-19 01:41 AM
vaporのはswift-nio上で実装されてたような?
(あんまり自信ないので見てみます)
Event-driven network application framework for high performance protocol servers & clients, non-blocking. - apple/swift-nio
Avatar
norio_nomura 09-Jul-19 03:39 AM
VaporのFuture, Promiseは swift-nio 版のtypealias + extension https://github.com/vapor/core/blob/master/Sources/Async/Async%2BNIO.swift#L4-L8 swift-nioにはストリームぽいのは無かったと思う。 (edited)
🌎 Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging. - vapor/core
Avatar
t.ae 09-Jul-19 03:55 AM
肝心のそっちを貼るのを忘れてました💦
typealiasのせいで補完が毎回EventLoopFutureになってちょっと長いのが気にならないでもない
Avatar
omochimetaru 09-Jul-19 06:22 AM
ストリームの方がスコープとしては広いので置き換えりゃいいってもんでもないので悩ましいですね
Avatar
kateinoigakukun 11-Jul-19 08:48 AM
@swift-nightly -Xfrontend -emit-sil -O
protocol Observable { associatedtype Element func subscribe(_ f: @escaping (Element) -> Void) } struct Just<T>: Observable { typealias Element = T let value: T func subscribe(_ f: @escaping (T) -> Void) { f(value) } } struct Map<Source: Observable, U>: Observable { typealias Element = U let source: Source let transformer: (Source.Element) -> U func subscribe(_ f: @escaping (U) -> Void) { source.subscribe { [transformer] element in f(transformer(element)) } } } extension Observable { func map<U>(_ f: @escaping (Element) -> U) -> Map<Self, U> { return Map(source: self, transformer: f) } } Just(value: 122) .map { $0.description } .map { $0.count } .subscribe { element in print(element.description) }
Avatar
swiftNightly BOT 11-Jul-19 08:48 AM
sil_stage canonical import Builtin import Swift import SwiftShims protocol Observable { associatedtype Element func subscribe(_ f: @escaping (Self.Element) -> ()) } struct Just<T> : Observable { typealias Element = T @_hasStorage let value: T { get } func subscribe(_ f: @escaping (T) -> ()) init(value: T) } struct Map<Source, U> : Observable where Source : Observable { typealias Element = U @_hasStorage let source: Source { get } @_hasStorage let transformer: (Source.Element) -> U { get } func subscribe(_ f: @escaping (U) -> ()) init(source: Source, transformer: @escaping (Source.Element) -> U) } extension Observable { func map<U>(_ f: @escaping (Self.Element) -> U) -> Map<Self, U> } // _swiftEmptyArrayStorage sil_global @_swiftEmptyArrayStorage : $_SwiftEmptyArrayStorage // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int64, 122 // user: %3 %3 = struct $Int (%2 : $Builtin.Int64) // users: %6, %4 debug_value %3 : $Int, let, name "$0", argno 1 // id: %4 %5 = alloc_stack $Int // users: %9, %8, %6 store %3 to %5 : $*Int // id: %6 // function_ref BinaryInteger.description.getter %7 = function_ref @$sSzsE11descriptionSSvg : $@convention(method) <τ_0_0 where τ_0_0 : BinaryInteger> (@in_guaranteed τ_0_0) -> @owned String // users: %32, %8 %8 = apply %7<Int>(%5) : $@convention(method) <τ_0_0 where τ_0_0 : BinaryInteger> (@in_guaranteed τ_0_0) -> @owned String // users: %51, %10, %11, %12, %14 dealloc_stack %5 : $*Int // id: %9 debug_value %8 : $String, let, name "element", argno 1 // id: %10 debug_value %8 : $String, let, name "element", argno 1 // id: %11 debug_value %8 : $String, let, name "$0", argno 1 // id: %12 // function_ref String.count
Avatar
kateinoigakukun 11-Jul-19 08:49 AM
このくらい単純だと全部スペシャライズとインライン化で消えるし、Combineもそうなってほしい
うーん、Combine実験してみたけど特にspecializeされなくてあんまり嬉しみが無い・・・
Avatar
norio_nomura 11-Jul-19 09:57 AM
@inlinableにした時点で実装が丸見えですからね。AppleがCombineをOSSにするつもりがなければ無理そう。
Avatar
kateinoigakukun 11-Jul-19 09:57 AM
Combineに関しては隠す必要あるのかなぁ、という感じですけど。
Avatar
omochimetaru 11-Jul-19 09:58 AM
オープンソースでよいやんね
Avatar
kateinoigakukun 11-Jul-19 10:00 AM
OSに同梱されてるフレームワークに関してはクローズドにしておく、みたいなポリシーなのかな (edited)
Avatar
omochimetaru 11-Jul-19 10:07 AM
インライン化するとライブラリのアップデートができないという問題は、まあ、ある
Avatar
kateinoigakukun 11-Jul-19 10:09 AM
うーん、まあそれはそう…
Avatar
koher 11-Jul-19 10:12 AM
標準ライブラリが specialize できるのはなんでだっけ?
Avatar
omochimetaru 11-Jul-19 10:13 AM
あれは中身見えてますね
Avatar
koher 11-Jul-19 10:13 AM
OSに同梱されてるフレームワークに関してはクローズドにしておく、みたいなポリシーなのかな
一応 Foundation はオープンだから、 Combine も同じで良さそうな気も。
あれは中身見えてますね
中身が見えるかじゃなくて、ライブラリのアップデートができないという問題について。
(edited)
Avatar
omochimetaru 11-Jul-19 10:14 AM
インライン化されたアプリは実装改善の恩恵は受けられないと思います
そういう余地が無い自明な処理しかinlinableつけてない気がする
transparentもありますね
Avatar
koher 11-Jul-19 10:15 AM
標準ライブラリレベルでそれやってるなら Combine でも良さそうだと思ったけど、まだ安定性が違いすぎるのか。
Avatar
omochimetaru 11-Jul-19 10:16 AM
Combineの中身に関しては単純なmapでもストリームオブジェクトの構築とかが絡むので
実装が自明じゃなさそうなので渋る気持ちはわかる
Avatar
norio_nomura 11-Jul-19 10:18 AM
OS標準フレームワークを立ち上げ時点からOSSにするのは難しそう。
Avatar
koher 11-Jul-19 10:19 AM
今は無理でも Combine はそのうちオープンソース化はありそう。
😄 1
Avatar
norio_nomura 11-Jul-19 11:55 PM
この記事は、RxSwift, ReactiveSwiftよりCombineの方が速いと書いてる。 https://medium.com/flawless-app-stories/problem-solving-with-combine-swift-4751885fda77
Combine has many benefits: simple asynchronous code, simplified multithreading, compassable components. Let’s learn Combine essentials and see what practical problems we can solve with it.
Avatar
tarunon 12-Jul-19 12:06 AM
Combineにインライン化して消える最適化がなくても、RxSwiftは内部的にはサブクラス化していてvtableの参照が沢山あるので、納得感のある結果に見えます。 (edited)
Avatar
norio_nomura 16-Jul-19 02:58 AM
@swift-5.0.3
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift50 BOT 16-Jul-19 02:58 AM
5.0.2-RELEASE
Avatar
norio_nomura 18-Jul-19 03:14 AM
@swift-5.1.5
@available(macCatalyst 13.0, *) func f() {}
Avatar
swift51 BOT 18-Jul-19 03:14 AM
stderr:
<stdin>:1:28: warning: unrecognized platform name 'macCatalyst' @available(macCatalyst 13.0, *) ^
Avatar
norio_nomura 18-Jul-19 03:18 AM
認識するのはまだXcode 11 beta 4だけか。
Avatar
norio_nomura 18-Aug-19 10:41 AM
@swift-5.1.5
import Foundation print(FileManager.default.fileExists(atPath: "/usr/bin/sourcekit-lsp"))
Avatar
swift51 BOT 18-Aug-19 10:41 AM
true
Avatar
norio_nomura 18-Aug-19 10:42 AM
sourcekit-lspがtoolchainに含まれる様になったのか。
Avatar
omochimetaru 19-Aug-19 04:55 AM
とっくに含まれてると思いこんでた。
Avatar
norio_nomura 29-Aug-19 03:02 AM
@swift-nightly
struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder = Adder(base: 3) print(adder(10)) // 13
Avatar
swiftNightly BOT 29-Aug-19 03:02 AM
13
Avatar
Kishikawa Katsumi 29-Aug-19 03:24 AM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
call-syntax can also be useful for other values ... , parsers ... というところ割と同意。
Avatar
omochimetaru 29-Aug-19 03:27 AM
func callAsFunction has been merged and is available in latest development snapsnots from swift.org/download. I just tested swift-DEVELOPMENT-SNAPSHOT-2019-08-27-a: struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder =...
なんちゃらParserとかLoaderとかConverterとか 〜〜er系のクラスって、補助的なパラメータをカスタムするためのプロパティと、対応するparse(), load(), convert() とかを呼ぶだけのインターフェースになることがわりとあるので
Avatar
Kishikawa Katsumi 29-Aug-19 03:29 AM
まあしかしだいぶ単純な名前を予約したな。
Avatar
omochimetaru 29-Aug-19 03:29 AM
そういうケースでこれ使うとよさそうっすね
はい、そのへんの名前はめっちゃ議論がぐるぐるして
Avatar
t.ae 29-Aug-19 03:30 AM
確かもとはcallだったはずw
Avatar
omochimetaru 29-Aug-19 03:30 AM
最初はcallに落ち着きそうだったんだけどcallFunctionになってcallAsFunctionになっていった
メソッド名無しとか
funcの代わりに新しい予約語としてcallで定義するとかの案もありました。 (edited)
Avatar
Kishikawa Katsumi 29-Aug-19 03:31 AM
まあでもコールサイトの問題だから影響はないのか。
func call()でも
Avatar
omochimetaru 29-Aug-19 03:32 AM
使う側からするとどうせ見えないっすね
でも僕はfunc callが良かったな・・・ (edited)
Avatar
Kishikawa Katsumi 29-Aug-19 03:33 AM
まあこのマニアックな言語仕様を知らなかったらわからんというのはある。 func call() だと
Avatar
omochimetaru 29-Aug-19 03:33 AM
@callableとかもあったな。
Avatar
Kishikawa Katsumi 29-Aug-19 03:34 AM
Codableとかはなんとなく知識の延長でわかる気がするけど func callAsFuncion() は閃きが必要じゃないか。
@callableはいいんじゃない。
Avatar
t.ae 29-Aug-19 03:34 AM
特に違和感なくcallAsFunction使ってましたけど仕様知らなかったら完全に意味不明ですね……
Avatar
omochimetaru 29-Aug-19 03:34 AM
特殊な事が起こる感があってググりやすそうですよね
アトリビュート増やしまくるのやめてくれ〜みたいな反論もあった
結局コアチームの言うcallがダメな最大の理由は、それまでにたまたま使われたcallに新しい意味が衝突するのは良くないって事だったと記憶 (edited)
つまりこの仕様が出るのがSwift2.0とかだったらcallになった可能性もあるって事で
保守的になったなあ、と思った。
Avatar
Kishikawa Katsumi 29-Aug-19 03:37 AM
callAsFunctionでも一緒だけど、その辺は柔軟だなあ
Avatar
omochimetaru 29-Aug-19 03:37 AM
そうですね、確率的に多いだろう、って話ですね (edited)
Avatar
Kishikawa Katsumi 29-Aug-19 03:38 AM
まあ本質的に一緒だけどcallよりだいぶマシというのはわかります。
Avatar
omochimetaru 29-Aug-19 03:38 AM
それでcallFunctionが出て、それ英語的に命名がおかしい、ってなってcallAsFunctionになっていった。
Avatar
masakihori 29-Aug-19 06:38 AM
@swift-nightly
struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder = Adder(base: 3) [1].map(adder).forEach { print($0) }
Avatar
swiftNightly BOT 29-Aug-19 06:38 AM
exit status: 1 with stderr:
<stdin>:10:5: error: cannot invoke 'map' with an argument list of type '(Adder)' [1].map(adder).forEach { print($0) } ^
Avatar
masakihori 29-Aug-19 06:38 AM
あ、はい
@swift-nightly
struct Adder { var base: Int func callAsFunction(_ x: Int) -> Int { return x + base } } var adder = Adder(base: 3) [1].map(adder.callAsFunction).forEach { print($0) }
Avatar
swiftNightly BOT 29-Aug-19 06:44 AM
4
Avatar
masakihori 29-Aug-19 06:44 AM
.initと同じ扱い的な
Avatar
norio_nomura 31-Aug-19 12:46 AM
@swift-5.0.3 -version
Avatar
swift50 BOT 31-Aug-19 12:46 AM
Swift version 5.0.3 (swift-5.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
taketo1024 07-Sep-19 01:50 PM
@swift-5.0.3 --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath let a = RationalNumber(2, 3) print(a)
Avatar
swift50 BOT 07-Sep-19 01:50 PM
exit status: 1 with stderr:
<unknown>:0: error: unknown argument: '--options="-I'
Avatar
taketo1024 07-Sep-19 01:50 PM
どうやるんだったかw
@swift-5.0.3
import SwiftyMath let a = RationalNumber(2, 3) print(a)
Avatar
swift50 BOT 07-Sep-19 01:50 PM
exit status: 1 with stderr:
<stdin>:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
Avatar
taketo1024 07-Sep-19 01:52 PM
@swiftbot --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath let a = RationalNumber(2, 3) print(a)
(edited)
🛠 1
Avatar
swiftbot BOT 07-Sep-19 01:52 PM
(edited)
Author icon taketo1024
import SwiftyMath let a = RationalNumber(2, 3) print(a)
Version:
swift-4.2.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
Avatar
taketo1024 07-Sep-19 01:55 PM
@swiftbot --options="-I /vendor/SwiftyMath/.build/release/ -I /usr/lib/swift/clang/include/ -I /vendor/swift-package-libbsd/ -L /vendor/SwiftyMath/.build/release/ -ldSwiftyMath"
import SwiftyMath let a = RationalNumber(2, 3) print(a)
🛠 1
Avatar
swiftbot BOT 07-Sep-19 01:55 PM
Author icon taketo1024
import SwiftyMath let a = RationalNumber(2, 3) print(a)
Version:
swift-4.2.1-RELEASE
Output:
Error:
/usercode/main.swift:1:8: error: no such module 'SwiftyMath' import SwiftyMath ^
Avatar
taketo1024 07-Sep-19 01:55 PM
ビルドが通らなくなったりしてたから外してあるのかな
Avatar
taketo1024 07-Sep-19 02:03 PM
@swiftbot -version
うーむw
Avatar
norio_nomura 09-Sep-19 04:43 AM
最近、ここ見てませんでした、ごめんなさい。
ビルドが通らなくなったりしてたから外してあるのかな
外してあります。4.2はオプション無しでインポート可能です。 @swift-4.2.4
import SwiftyMath
Avatar
swift42 BOT 09-Sep-19 04:50 AM
no output
Avatar
taketo1024 09-Sep-19 11:55 AM
了解です,ありがとうございます!
こちらこそビルド通らないまま放置してしまってすみません 🙇
@swift-4.2.4
import SwiftyMath typealias AlgebraicExtension<F, p: IrrPolynomialTP> = PolynomialQuotientRing<p> where p.CoeffRing == F typealias Q = RationalNumber typealias Qx = xPolynomial<Q> let x = Qx.indeterminate struct p1: IrrPolynomialTP { static let value = Qx(coeffs: -2, 0, 1) } typealias A = AlgebraicExtension<Q, p1> // A = Q[x]/p1 let α = A(x) print(α) print(α * α) print(α * α == 2) struct p2: IrrPolynomialTP { static let value = xPolynomial<Q>(coeffs: 1, 0, 1) } typealias B = AlgebraicExtension<Q, p2> // B = Q[x]/p2 let i = B(x) print(i) print(i * i) print(i * i == -1)
(edited)
Avatar
swift42 BOT 09-Sep-19 11:56 AM
exit status: 1 with stderr:
<stdin>:4:7: error: use of undeclared type 'PolynomialQuotientRing' = PolynomialQuotientRing<p> where p.CoeffRing == F ^~~~~~~~~~~~~~~~~~~~~~ <stdin>:7:16: error: use of undeclared type 'xPolynomial' typealias Qx = xPolynomial<Q> ^~~~~~~~~~~ <stdin>:11:8: error: type 'p1' does not conform to protocol 'PolynomialTP' struct p1: IrrPolynomialTP { ^ SwiftyMath.PolynomialTP:2:20: note: protocol requires nested type 'CoeffRing'; do you want to add it? associatedtype CoeffRing : Ring ^ SwiftyMath.PolynomialTP:3:20: note: protocol requires nested type 'x'; do you want to add it? associatedtype x : Indeterminate ^ <stdin>:24:24: error: use of unresolved identifier 'xPolynomial' static let value = xPolynomial<Q>(coeffs: 1, 0, 1) ^~~~~~~~~~~ SwiftyMath.MPolynomial:1:15: note: did you mean 'MPolynomial'? public struct MPolynomial<R> : Ring, Module where R : Ring { ^ SwiftyMath._Polynomial:1:15: note: did you mean '_Polynomial'? public struct _Polynomial<T, R, x> : Ring, Module where T : PolynomialType, R : Ring, x : Indeterminate { ^ SwiftyMath.Polynomial:1:18: note: did you mean 'Polynomial'? public typealias Polynomial<R, x> = SwiftyMath._Polynomial<SwiftyMath.NormalPolynomialType, R, x> ^ <stdin>:23:8: error: type 'p2' does not conform to protocol 'PolynomialTP' struct p2: IrrPolynomialTP { ^ SwiftyMath.PolynomialTP:2:20: note: protocol requires nested type 'CoeffRing'; do you want to add it? associatedtype CoeffRing : Ring ^ SwiftyMath.PolynomialTP:3:20: note: protocol requires nested type 'x'; do you want to add it? associatedtype x : Indeterminate ^
Avatar
taketo1024 09-Sep-19 11:57 AM
あぁ,やはりw
Swift 5.1 正式リリースのタイミングで master も更新しておくので,そのときにでもまた組み込んで頂けると嬉しいです 🙇
👍 1
Avatar
norio_nomura 09-Sep-19 12:35 PM
どのバージョンのSwiftで動くのかがCIやドキュメントから判ると、対応がしやすいと思います。 あと、バージョニングのルールもSemVerに従ってもらえてると、リリースwatchで気づきやすくなります。
Avatar
taketo1024 09-Sep-19 02:10 PM
これを機に CI 導入するのはありな気がしてきました.
Avatar
norio_nomura 19-Sep-19 09:36 PM
@swift-5.1.5 -version
Avatar
swift51 BOT 19-Sep-19 09:36 PM
Swift version 5.1 (swift-5.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
nanasi 20-Sep-19 04:02 AM
@swift-5.1.5
@dynamicMemberLookup struct Foo<Content> { let content: Content subscript<T>(dynamicMember keyPath: KeyPath<Content, T>) -> T { return content[keyPath: keyPath] } } print(Foo<Int>(content: 100).description)
Avatar
swift51 BOT 20-Sep-19 04:02 AM
100
Avatar
nanasi 20-Sep-19 04:03 AM
@swift-5.1.5
struct Foo<Content> { let content: Content } @dynamicMemberLookup extension Foo { subscript<T>(dynamicMember keyPath: KeyPath<Content, T>) -> T { return content[keyPath: keyPath] } } print(Foo<Int>(content: 100).description)
Avatar
swift51 BOT 20-Sep-19 04:03 AM
exit status: 1 with stderr:
<stdin>:5:1: error: '@dynamicMemberLookup' attribute cannot be applied to this declaration @dynamicMemberLookup ^~~~~~~~~~~~~~~~~~~~ <stdin>:12:30: error: value of type 'Foo<Int>' has no member 'description' print(Foo<Int>(content: 100).description) ~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~
Avatar
t.ae 20-Sep-19 08:43 AM
@swift-4.2.4 @swift-5.0.3
class Parent { var id: Int init(id: Int) { self.id = id } } protocol Abstract: Parent { func printID() } class Child: Parent, Abstract { override init(id: Int) { super.init(id: id) } func printID() { print("Child: \(id)") } } let c = Child(id: 0) c.printID()
Avatar
swift50 BOT 20-Sep-19 08:43 AM
Child: 0
Avatar
swift42 BOT 20-Sep-19 08:43 AM
exit status: 1 with stderr:
<stdin>:9:10: error: non-class type 'Abstract' cannot inherit from class 'Parent' protocol Abstract: Parent { ^ ~~~~~~
Avatar
t.ae 20-Sep-19 08:45 AM
Swift4.2だと特定クラス条件のプロトコル作れないんですっけ? vaporが公式で用意してるaptリポジトリのバージョンが4.2なので困った (edited)
Avatar
t.ae 20-Sep-19 09:11 AM
@swift-4.2.4 @swift-5.0.3
class Parent { var id: Int init(id: Int) { self.id = id } } protocol Abstract where Self: Parent { var name: String { get } } extension Abstract { func printProfile() { print("\(id) \(name)") } } class Child: Parent, Abstract { var name: String init(id: Int, name: String) { self.name = name super.init(id: id) } } let c = Child(id: 42, name: "hoge") c.printProfile()
Avatar
swift50 BOT 20-Sep-19 09:11 AM
42 hoge
Avatar
swift42 BOT 20-Sep-19 09:11 AM
42 hoge
Avatar
t.ae 20-Sep-19 09:11 AM
Self: Parentなら使えると教えてもらいました。
Avatar
t.ae 04-Oct-19 01:31 AM
@swift-4.2.4
import Foundation let locale = Locale(identifier: "ja") let data = try JSONEncoder().encode(locale) let decoded = try JSONDecoder().decode(Locale.self, from: data) print(locale == decoded) print(locale.hashValue == decoded.hashValue)
Avatar
swift42 BOT 04-Oct-19 01:31 AM
true false
Avatar
t.ae 04-Oct-19 01:32 AM
Dictionaryで引っかからないと思ったらバグかこれ(5以降は治っている)
Avatar
omochimetaru 04-Oct-19 01:32 AM
やばすぎw
Avatar
norio_nomura 04-Oct-19 01:44 AM
darwinとswift-corelibs-foundationで非互換になってたのか。 (edited)
Avatar
omochimetaru 04-Oct-19 02:02 AM
非互換もまずいけど、そもそも ==なのに hashValueが同一にならないのはHashableとして誤りですね
辞書に入れてもバグるので使い物にならない
Avatar
tarunon 04-Oct-19 02:03 AM
これ多分中にNSObjectが入ってたせいだと思うんですよね
Avatar
t.ae 04-Oct-19 02:03 AM
https://bugs.swift.org/browse/SR-8448 ==だけ上書きしたせいとのこと。 (edited)
Avatar
omochimetaru 04-Oct-19 02:08 AM
そりゃあかんな。
常にセットで実装しないと。
Avatar
norio_nomura 04-Oct-19 04:25 AM
* Archive NSLocale identifier as NSString * Override isEqual for NSLocale * Uncomment NSLocale archiving test
Avatar
norio_nomura 05-Oct-19 01:54 AM
@swift-5.1.5 -version
Avatar
swift51 BOT 05-Oct-19 01:54 AM
Swift version 5.1.1 (swift-5.1.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
nanasi 08-Oct-19 01:57 AM
@swift-5.1.5
@propertyWrapper struct Foo<Value> { var wrappedValue: Value var projectedValue: Self { self } } protocol Namespace { typealias MyFoo = Foo } struct Test { @Foo var val = 0 } struct MyTest: Namespace { @MyFoo var val = 0 } let t1 = Test() print(t1.val, t1.$val) let t2 = MyTest() print(t2.val, t2.$val)
(edited)
Avatar
swift51 BOT 08-Oct-19 01:58 AM
exit status: 1 with stderr:
<stdin>:18:5: error: unknown attribute 'MyFoo' @MyFoo ^ <stdin>:26:18: error: value of type 'MyTest' has no member '$val' print(t2.val, t2.$val) ~~ ^~~~
(edited)
Avatar
Kishikawa Katsumi 14-Oct-19 04:58 PM
@swiftbot versions
Avatar
swiftbot BOT 14-Oct-19 04:58 PM
2019-10-13-a 5.1 5.0.3 5.0.2 5.0.1 5.0 4.2.2 4.2.1 4.1.3 4.1.2 4.1.1 4.1 4.0.3 4.0.2 4.0 3.1.1 3.1 3.0.2 3.0.1
Avatar
Kishikawa Katsumi 14-Oct-19 04:58 PM
5.x と最新のスナップショットサポートした。
🎊 2
Avatar
t.ae 17-Oct-19 05:04 AM
@swiftbot
let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
(edited)
🛠 1
Avatar
swiftbot BOT 17-Oct-19 05:04 AM
(edited)
Author icon t.ae
let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
Version:
swift-4.2.1-RELEASE
Output:
Error:
/usercode/main.swift:10:12: error: cannot convert return expression of type '[(Int, String)]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:6:21: warning: 'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^ /usercode/main.swift:6:21: note: use 'compactMap(_:)' instead let results1 = rows.flatMap { row in ^~~~~~~ compactMap
Avatar
Kishikawa Katsumi 17-Oct-19 05:06 AM
あれ、デフォルトが4.2のままか?
Avatar
t.ae 17-Oct-19 05:06 AM
デフォ4.2.1みたいですね。
(上コードは5.1でもコンパイルできないやつです。)
Avatar
Kishikawa Katsumi 17-Oct-19 05:10 AM
@swiftbot
let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
🛠 1
Avatar
swiftbot BOT 17-Oct-19 05:10 AM
Author icon kishikawakatsumi
let rows: [(id: Int, name1: String, name2: String)] = [ (0, "x", "y"), (1, "z", "w") ] let results1 = rows.flatMap { row in var entries = [(Int, String)]() entries.append((row.id, row.name1)) entries.append((row.id, row.name2)) return entries }
Version:
swift-5.1-RELEASE
Output:
Error:
/usercode/main.swift:10:12: error: cannot convert return expression of type '[(Int, String)]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:6:21: error: 'flatMap' has been renamed to 'compactMap(_:)': Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^~~~~~~ compactMap Swift.Collection:3:17: note: 'flatMap' was obsoleted in Swift 5.0 public func flatMap(_ transform: (Self.Element) throws -> String?) rethrows -> [String] ^
Avatar
Kishikawa Katsumi 17-Oct-19 05:11 AM
エラーメッセージ変わったし、5.1デフォルトになった。
Avatar
hironytic 17-Oct-19 10:17 AM
@swiftbot
let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
🛠 1
Avatar
swiftbot BOT 17-Oct-19 10:17 AM
Author icon hironytic
let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
Version:
swift-5.1-RELEASE
Output:
Error:
/usercode/main.swift:5:12: error: cannot convert return expression of type '[Int]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:2:21: error: 'flatMap' has been renamed to 'compactMap(_:)': Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^~~~~~~ compactMap Swift.Collection:3:17: note: 'flatMap' was obsoleted in Swift 5.0 public func flatMap(_ transform: (Self.Element) throws -> String?) rethrows -> [String] ^
Avatar
hironytic 17-Oct-19 10:18 AM
訳がわからない 😶
Avatar
tarunon 17-Oct-19 10:27 AM
@swiftbot
let rows = [10, 20] let results1 = rows.flatMap { row -> [Int] in var entries = [Int]() entries.append(row) return entries }
🛠 1
Avatar
swiftbot BOT 17-Oct-19 10:27 AM
Author icon tarunon
let rows = [10, 20] let results1 = rows.flatMap { row -> [Int] in var entries = [Int]() entries.append(row) return entries }
Version:
swift-5.1-RELEASE
Output:
Error:
Avatar
tarunon 17-Oct-19 10:27 AM
型推論壊れてるみたいですねぇ
Avatar
Kishikawa Katsumi 17-Oct-19 10:35 AM
@swiftbot --version 2019-10-13-a
let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
🛠 1
Avatar
swiftbot BOT 17-Oct-19 10:35 AM
Author icon kishikawakatsumi
let rows = [10, 20] let results1 = rows.flatMap { row in var entries = [Int]() entries.append(row) return entries }
Version:
swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a
Output:
Error:
/usercode/main.swift:5:12: error: cannot convert return expression of type '[Int]' to return type 'String?' return entries ^~~~~~~ /usercode/main.swift:2:21: error: 'flatMap' has been renamed to 'compactMap(_:)': Please use compactMap(_:) for the case where closure returns an optional value let results1 = rows.flatMap { row in ^~~~~~~ compactMap Swift.Collection:3:17: note: 'flatMap' was obsoleted in Swift 5.0 public func flatMap(_ transform: (Self.Element) throws -> String?) rethrows -> [String] ^
Avatar
Kishikawa Katsumi 17-Oct-19 10:35 AM
Snapshotでも一緒やな
Avatar
nanasi 18-Oct-19 10:34 AM
@swift-4.2.4
struct View<Value> { typealias Value = Value var value: Value } print(View<Int>.Value.self)
Avatar
swift42 BOT 18-Oct-19 10:34 AM
exit status: 1 with stderr:
<stdin>:2:23: error: type alias 'Value' references itself typealias Value = Value ^ <stdin>:2:15: note: type declared here typealias Value = Value ^
Avatar
nanasi 18-Oct-19 10:35 AM
@swift-5.0.3
struct View<Value> { typealias Value = Value var value: Value } print(View<Int>.Value.self)
Avatar
swift50 BOT 18-Oct-19 10:35 AM
Int
Avatar
hironytic 30-Oct-19 02:33 AM
@swiftbot
let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 1, as: Int.self).littleEndian
🛠 1
Avatar
swiftbot BOT 30-Oct-19 02:33 AM
Author icon hironytic
let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 1, as: Int.self).littleEndian
Version:
swift-5.1-RELEASE
Output:
Error:
Fatal error: load from misaligned raw pointer Current stack trace: 0 libswiftCore.so 0x00007fc6a04293c0 swift_reportError + 50 1 libswiftCore.so 0x00007fc6a049a230 _swift_stdlib_reportFatalError + 69 2 libswiftCore.so 0x00007fc6a0395c07 <unavailable> + 3349511 3 libswiftCore.so 0x00007fc6a02453c0 UnsafeRawPointer.load<A>(fromByteOffset:as:) + 88 5 swift 0x000000000052826e <unavailable> + 1213038 6 swift 0x000000000052cb52 <unavailable> + 1231698 7 swift 0x000000000051cc2f <unavailable> + 1166383 8 swift 0x000000000050b468 <unavailable> + 1094760 9 swift 0x0000000000506de1 <unavailable> + 1076705 10 swift 0x00000000004a022d <unavailable> + 655917 ...
Avatar
omochimetaru 30-Oct-19 02:33 AM
オオオ(俺も今試してた
Avatar
hironytic 30-Oct-19 02:34 AM
@hironytic @d_date それ僕も思ったんですけど現状macとLinuxでアライメント違反って実行時エラー起きるんですかね?僕は気にして書いてますけど・・・
@swiftbot
let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 8, as: Int.self).littleEndian
🛠 1
Avatar
swiftbot BOT 30-Oct-19 02:35 AM
Author icon hironytic
let a: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] let b = UnsafeRawPointer(a).load(fromByteOffset: 8, as: Int.self).littleEndian
Version:
swift-5.1-RELEASE
Output:
Error:
Avatar
hironytic 30-Oct-19 02:36 AM
アラインメントに合った8なら大丈夫。
Avatar
omochimetaru 30-Oct-19 02:38 AM
@swift-5.1.5
import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] let a = array.withUnsafeBufferPointer { (buf) -> Int in buf.baseAddress!.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in buf.baseAddress!.advanced(by: 1).withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) print(MemoryLayout<Int>.size)
Avatar
swift51 BOT 30-Oct-19 02:38 AM
4131211140302010 true 9941312111403020 true 8
Avatar
omochimetaru 30-Oct-19 02:38 AM
あれ、もしかして、withMemoryReboundってアライメント治すの?
@swift-5.1.5
import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] func reboundToInt(pointer: UnsafePointer<UInt8>) -> Int { return pointer.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } func assumeToInt(pointer: UnsafePointer<UInt8>) -> Int { return UnsafeRawPointer(pointer).assumingMemoryBound(to: Int.self).pointee } let a = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) let c = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", c), c == Int(bitPattern: 0x4131211140302010)) let d = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", d), d == Int(bitPattern: 0x9941312111403020))
Avatar
swift51 BOT 30-Oct-19 02:41 AM
4131211140302010 true 9941312111403020 true 4131211140302010 true 9941312111403020 true
Avatar
omochimetaru 30-Oct-19 02:44 AM
@swift-5.1.5
import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] func reboundToInt(pointer: UnsafePointer<UInt8>) -> Int { return pointer.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } func assumeToInt(pointer: UnsafePointer<UInt8>) -> Int { let intp = UnsafeRawPointer(pointer).assumingMemoryBound(to: Int.self) print("[assume] p: \(Int(bitPattern: pointer))") print("[assume] intp: \(Int(bitPattern: intp))") return intp.pointee } let a = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) let c = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", c), c == Int(bitPattern: 0x4131211140302010)) let d = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", d), d == Int(bitPattern: 0x9941312111403020))
Avatar
swift51 BOT 30-Oct-19 02:44 AM
4131211140302010 true 9941312111403020 true [assume] p: 156675312 [assume] intp: 156675312 4131211140302010 true [assume] p: 156675313 [assume] intp: 156675313 9941312111403020 true
Avatar
hironytic 30-Oct-19 02:45 AM
ええー
Avatar
omochimetaru 30-Oct-19 02:45 AM
@swift-5.1.5
import Foundation let array: [UInt8] = [ 0x10, 0x20, 0x30, 0x40, 0x11, 0x21, 0x31, 0x41, 0x99] func reboundToInt(pointer: UnsafePointer<UInt8>) -> Int { return pointer.withMemoryRebound(to: Int.self, capacity: 1) { (ip) in ip.pointee } } func assumeToInt(pointer: UnsafePointer<UInt8>) -> Int { let intp = UnsafeRawPointer(pointer).assumingMemoryBound(to: Int.self) print("[assume] p: \(Int(bitPattern: pointer))") print("[assume] intp: \(Int(bitPattern: intp))") return intp.pointee } func loadAsInt(pointer: UnsafePointer<UInt8>) -> Int { return UnsafeRawPointer(pointer).load(as: Int.self) } let a = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", a), a == Int(bitPattern: 0x4131211140302010)) let b = array.withUnsafeBufferPointer { (buf) -> Int in reboundToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", b), b == Int(bitPattern: 0x9941312111403020)) let c = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", c), c == Int(bitPattern: 0x4131211140302010)) let d = array.withUnsafeBufferPointer { (buf) -> Int in assumeToInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", d), d == Int(bitPattern: 0x9941312111403020)) let e = array.withUnsafeBufferPointer { (buf) -> Int in loadAsInt(pointer: buf.baseAddress!) } print(String(format: "%016llx", e), e == Int(bitPattern: 0x4131211140302010)) let f = array.withUnsafeBufferPointer { (buf) -> Int in loadAsInt(pointer: buf.baseAddress!.advanced(by: 1)) } print(String(format: "%016llx", f), f == Int(bitPattern: 0x9941312111403020))
(edited)
Avatar
swift51 BOT 30-Oct-19 02:45 AM
exit status: 4 with stderr:
Fatal error: load from misaligned raw pointer Current stack trace: 0 libswiftCore.so 0x00007f98e95ea3c0 swift_reportError + 50 1 libswiftCore.so 0x00007f98e965b230 _swift_stdlib_reportFatalError + 69 2 libswiftCore.so 0x00007f98e9556c07 <unavailable> + 3349511 3 libswiftCore.so 0x00007f98e94063c0 UnsafeRawPointer.load<A>(fromByteOffset:as:) + 88 8 libswiftCore.so 0x00007f98e93633b0 Array.withUnsafeBufferPointer<A>(_:) + 38 10 swift 0x00000000005283fe <unavailable> + 1213438 11 swift 0x000000000052cce2 <unavailable> + 1232098 12 swift 0x000000000051cdbf <unavailable> + 1166783 13 swift 0x000000000050b5e8 <unavailable> + 1095144 14 swift 0x0000000000506f41 <unavailable> + 1077057 15 swift 0x00000000004a033d <unavailable> + 656189 16 libc.so.6 0x00007f98ec28a740 __libc_start_main + 240 17 swift 0x000000000049feb9 <unavailable> + 655033 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux/debug -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/OpenCombine/Sources/COpenCombineHelpers/include -module-cache-path /Libraries/.build/x86_64-unknown-linux/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=
(edited)
Avatar
omochimetaru 30-Oct-19 02:46 AM
なるほど〜〜〜
UnsafePointer<T>の.pointeeはmemcpy semanticsだからアライメントエラーは起きないんだ
UnsafeRawPointerの.loadが本当の生のポインターデリファレンスで、こっちはエラーが起きる。
知らなかった。
Avatar
hironytic 30-Oct-19 02:49 AM
知りませんでした。。。
Avatar
omochimetaru 30-Oct-19 02:50 AM
つまり、メモリレイアウトレベルのハードキャストをしたいだけの状況であれば、UnsafePointer<T>を使う限りアライメントのことは忘れてよいっぽいですね
一方で、最高速度を求めてメモリ操作したいのであれば、非効率な場合に死んでくれるUnsafeRawPointerを使ったほうが良い・・・?
なんかそれも微妙な話だな。型ないし。
Avatar
hironytic 30-Oct-19 02:52 AM
あ、でも、これってfatalErrorが出てるだけ?もしかして、fatalErrorが入ってなければ単に落ちないかもだけな可能性もある?
最適化オプションで挙動が変わったりとかしないですかね。
Avatar
omochimetaru 30-Oct-19 03:49 AM
fatalErrorが呼ばれているので本当に処理系からメモリ違反シグナル等が飛んでいるわけではないですね。 でもfatalErrorに関しては-Ouncheckedでも無効化しないです。 uncheckedで消せるのはprecondition。 (edited)
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
むむ、debugPreconditionだ。
4131211140302010 true 9941312111403020 true [assume] p: 4300947488 [assume] intp: 4300947488 4131211140302010 true [assume] p: 4300947489 [assume] intp: 4300947489 9941312111403020 true 4131211140302010 true 9941312111403020 true Program ended with exit code: 0
手元のmac環境ではReleaseにするだけで通過しました。
Avatar
hironytic 30-Oct-19 05:00 AM
なるほど。
Avatar
hironytic 30-Oct-19 10:34 PM
手元のiPod touchでも、Releaseにするだけでおもちさんのコードが通過して全部trueになったので、アライメント違反で実行時エラーになるデバイスは今のところないのかも。
Avatar
norio_nomura 06-Nov-19 12:11 AM
Swift Compiler Bot on macOSを動かすのに使えないかな。 https://www.macstadium.com/opensource
Encouraging innovation through collaboration is one of MacStadium’s core beliefs. We know that despite finite resources, a lack of hardware, and limited support, tremendously important innovation is happening through free and open source software. Learn how MacStadium is he...
Avatar
omochimetaru 06-Nov-19 12:13 AM
おお!
Avatar
Kishikawa Katsumi 06-Nov-19 12:17 AM
おおー
PublicリポジトリならOKなのかな。とりあえず先に進んでみよう。
Avatar
Kishikawa Katsumi 06-Nov-19 12:39 AM
Formを送信したら今度はProject Logoを送る必要があるらしいけどどうするべきか。
なんかロゴを作るしかない。
Avatar
tarunon 06-Nov-19 12:40 AM
ロボットの鳥の絵を描けば良いのかな
Avatar
Kishikawa Katsumi 06-Nov-19 12:43 AM
おお!助かります😇
Avatar
tarunon 06-Nov-19 12:45 AM
参考資料です
Avatar
tarunon 06-Nov-19 01:11 AM
@kishikawakatsumi ペン入れツール無かったので線がぐちゃってしまった!
Avatar
omochimetaru 06-Nov-19 01:12 AM
Linuxっぽい
Avatar
tarunon 06-Nov-19 01:12 AM
もうちょっとお目々大きくしても良いかも
Avatar
Kishikawa Katsumi 06-Nov-19 01:12 AM
これはいいですね!
参考資料が何の参考になったかサッパリわからないけど、出てきたものはすばらしい。
Avatar
omochimetaru 06-Nov-19 01:13 AM
Avatar
tarunon 06-Nov-19 01:13 AM
ペンギンなのはbotのためのツールなので飛べないと言うことで
これ差し替え可能ですか?ペン入れしたものを後日用意します
今日はそろそろ出ないと
あともうちょっとロボットっぽくしたい
Avatar
Kishikawa Katsumi 06-Nov-19 01:16 AM
ASAPって書いてあるけど、向こうからさらにメールが送られてくるらしいので、今すぐってことはないでしょう。時差もあるし。 というわけで納得がいくものができるまで保留しておくので、そんなに急がずやってください。
Avatar
tarunon 06-Nov-19 01:16 AM
わーい、ありがとうございます
🙏 1
Avatar
norio_nomura 06-Nov-19 02:02 AM
swiftってsandbox内で動くのかな?Xcode Serverはどうしてるのだろう?
Avatar
norio_nomura 06-Nov-19 02:58 AM
Xcode Serverはsandbox使ってなかった。XcodeのPlaygroundも、macOSはsandbox使ってなかった。
Avatar
koher 07-Nov-19 09:06 AM
@swift-5.1.5
if let line = readLine() { print(line) }
Avatar
swift51 BOT 07-Nov-19 09:06 AM
no output
Avatar
tarunon 07-Nov-19 02:00 PM
@Kishikawa Katsumi
ペン入れしてタイヤつけました。なんかちょっとアンバランスだな…
やっぱこっちの方がいいですね!
線太くしたいとかあれば対応するのでお知らせください〜 (edited)
Avatar
Kishikawa Katsumi 07-Nov-19 04:31 PM
下の方がいいですね。いったんこれを送ってみますよ。ありがとうございます😊
Avatar
norio_nomura 08-Nov-19 03:37 AM
@swift-5.1.5 -version
Avatar
swift51 BOT 08-Nov-19 03:37 AM
Swift version 5.1 (swift-5.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Kishikawa Katsumi 11-Nov-19 02:50 AM
Mac StadiumのOSS利用、許可されました 😄 (edited)
🎉 7
Avatar
omochimetaru 11-Nov-19 02:50 AM
おっ!!!
Avatar
Kishikawa Katsumi 11-Nov-19 02:52 AM
時間をみてMacホストのボットや、SwiftUI Playgroundとか作りたい。
Avatar
omochimetaru 11-Nov-19 02:52 AM
mac版のbotがあるととても便利そう
なんだかんだ時々挙動違うから。 (edited)
Avatar
Kishikawa Katsumi 11-Nov-19 02:56 AM
今のところ、フォームはそこそこ入力項目があったけどフォームで申請した以外のコミュニケーションは必要なかったので、簡単だった 😄
Avatar
t.ae 29-Nov-19 04:39 AM
@swift-5.1.5 @swift-5.0.3 @swift-4.2.4
public extension Int {}
Avatar
swift51 BOT 29-Nov-19 04:39 AM
no output
Avatar
swift42 BOT 29-Nov-19 04:39 AM
no output
Avatar
swift50 BOT 29-Nov-19 04:39 AM
no output
Avatar
omochimetaru 30-Nov-19 11:20 AM
@swift-5.1.5
class Animal {} func f(_ a: AnyObject) { } f(Animal.self)
Avatar
swift51 BOT 30-Nov-19 11:20 AM
exit status: 1 with stderr:
<stdin>:3:3: error: argument type 'Animal.Type' does not conform to expected type 'AnyObject' f(Animal.self) ^
Avatar
norio_nomura 01-Dec-19 01:26 AM
@swift-5.1.5 -version
Avatar
swift51 BOT 01-Dec-19 01:26 AM
Swift version 5.1.2 (swift-5.1.2-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 03-Dec-19 12:17 AM
@swift-5.0.3 @swift-5.1.5
struct Pair<T, U> { let values: (T, U) init(_ t: T, _ u: U) { values = (t, u) } } let pair = Pair(1, "2") print(pair[keyPath: \Pair.values.0]) print(pair[keyPath: \Pair.values.1])
Avatar
swift50 BOT 03-Dec-19 12:17 AM
exit status: 1 with stderr:
<stdin>:9:7: error: value of type 'Pair<Int, String>' has no subscripts print(pair[keyPath: \Pair.values.0]) ^~~~ <stdin>:10:7: error: value of type 'Pair<Int, String>' has no subscripts print(pair[keyPath: \Pair.values.1]) ^~~~
Avatar
swift51 BOT 03-Dec-19 12:17 AM
1 2
Avatar
norio_nomura 14-Dec-19 02:43 AM
@swift-5.1.5 -version
Avatar
swift51 BOT 14-Dec-19 02:43 AM
Swift version 5.1.3 (swift-5.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 24-Dec-19 12:27 AM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-nightly
let evens = (1...10).lazy .filter { ($0 % 2) == 0 } .filter { print($0, terminator: ","); return true } _ = evens.count
☠️ 1
Avatar
swift42 BOT 24-Dec-19 12:27 AM
2,4,6,8,10,
Avatar
swift41 BOT 24-Dec-19 12:27 AM
2,4,6,8,10,
Avatar
swift40 BOT 24-Dec-19 12:27 AM
2,4,6,8,10,
Avatar
swift50 BOT 24-Dec-19 12:27 AM
1,2,3,4,5,6,7,8,9,10,
Avatar
swift51 BOT 24-Dec-19 12:27 AM
1,2,3,4,5,6,7,8,9,10,
Avatar
swiftNightly BOT 24-Dec-19 12:27 AM
2,4,6,8,10,
Avatar
masakihori 24-Dec-19 01:44 AM
@swift-5.1.5
let evens = (1...10).lazy .filter { ($0 % 2) == 0 } .filter { print($0, terminator: ","); return true } print("\nfirst", evens.first!, "\ncount:", evens.count)
Avatar
swift51 BOT 24-Dec-19 01:44 AM
1,2,1,2,3,4,5,6,7,8,9,10, first 2 count: 5
Avatar
masakihori 24-Dec-19 01:45 AM
なるほど
Avatar
tarunon 06-Jan-20 01:27 PM
@swift-5.1.5 @swift-5.0.3
protocol A { func isEquatable() -> Bool } extension A { func isEquatable() -> Bool { return false } } extension A where Self: Equatable { func isEquatable() -> Bool { return true } } struct Foo: A { } extension String: A { } print(Foo().isEquatable()) print(String().isEquatable())
(edited)
Avatar
swift50 BOT 06-Jan-20 01:27 PM
false true
(edited)
Avatar
swift51 BOT 06-Jan-20 01:27 PM
false true
(edited)
Avatar
tarunon 06-Jan-20 01:28 PM
せや5.0.3はreturnいるんじゃ
これちょっと応用すればEquatableの時だけ動きを変えるのが簡単に書けそう
Avatar
kateinoigakukun 06-Jan-20 01:29 PM
なるほど、Existentialにできないプロトコルの is P が書けるのか
Avatar
tarunon 06-Jan-20 01:30 PM
ですね
ただなんか不安定な気がします。半分動かない
今手元に動かない型と動く型の混在したコードがあるが、分水嶺を見極められない
Avatar
omochimetaru 06-Jan-20 01:31 PM
<T: P> になってるコンテキストでちゃんと動くのかな?
isEquatableがAのrequirementsだから大丈夫か。
Avatar
tarunon 06-Jan-20 01:32 PM
動かないケースがあるんですよね
@swift-5.1.5
protocol A { func isEquatable() -> Bool } extension A { func isEquatable() -> Bool { return false } } extension A where Self: Equatable { func isEquatable() -> Bool { return true } } struct Foo: A { } struct Foo2: A, Equatable { } extension String: A { } print("direct") print(Foo().isEquatable()) print(Foo2().isEquatable()) print(String().isEquatable()) func generics<X: A>(arg: X) { print(arg.isEquatable()) } func existential(arg: A) { print(arg.isEquatable()) } print("from generics") generics(arg: Foo()) generics(arg: Foo2()) generics(arg: String()) print("from existential") existential(arg: Foo()) existential(arg: Foo2()) existential(arg: String())
(edited)
Avatar
swift51 BOT 06-Jan-20 01:34 PM
direct false true true from generics false true true from existential false true true
(edited)
Avatar
tarunon 06-Jan-20 01:34 PM
すまん
動いてるなぁ
Avatar
omochimetaru 06-Jan-20 01:34 PM
うん
Swift 5.1.?だとdynamic cond confが無かったからダメだったかも (edited)
Avatar
kateinoigakukun 06-Jan-20 01:35 PM
これはcond confいらないんじゃないですかね
Avatar
omochimetaru 06-Jan-20 01:36 PM
あ、ほんとだ
Avatar
kateinoigakukun 06-Jan-20 01:36 PM
静的にwitness tableが決定できる気がする
Avatar
tarunon 06-Jan-20 01:36 PM
いらないです
ただ手元のコードで半分動いてない
Avatar
omochimetaru 06-Jan-20 01:36 PM
きっと別のバグだ
Avatar
tarunon 06-Jan-20 02:08 PM
@swift-5.1.5
protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } print(AnyEquatable(value: "abc").isEqual(to: AnyEquatable(value: "abc"))) print(AnyEquatable(value: ()).isEqual(to: AnyEquatable(value: ()))) print(AnyEquatable(value: String.self).isEqual(to: AnyEquatable(value: String.self))) print(AnyEquatable(value: { }).isEqual(to: AnyEquatable(value: { })))
Avatar
swift51 BOT 06-Jan-20 02:08 PM
true false false false
Avatar
tarunon 06-Jan-20 02:08 PM
AnyEquatable2020だw
クソ便利な予感
これに包めば今動いてないやつも動きそうだな
Avatar
kateinoigakukun 06-Jan-20 02:12 PM
型パラによってwitness tableに載る実装を静的に切り替えるテクニック、結構使えそうですね
おもしろい
Avatar
tarunon 06-Jan-20 02:13 PM
最小ケース再現できてないですが、エッジケースで動かない
俺の頭がおかしいかもしれない
ちょっと飯作るので、動いてない途中のコミット貼っておきます。興味あったらチェックしてみて下さい。
Generate UIKit (not SwiftUI) components from FunctionBuilder. - tarunon/UIViewBuilder
Generate UIKit (not SwiftUI) components from FunctionBuilder. - tarunon/UIViewBuilder
Avatar
kateinoigakukun 06-Jan-20 02:19 PM
inline(__always)の挙動ちゃんと把握してないんですけど、これ付いててもwitness method経由で呼ばれるんですかね
Avatar
tarunon 06-Jan-20 02:19 PM
他の場所でもやってるので大丈夫です
インライン化されてるかはわからないですが… (edited)
Generate UIKit (not SwiftUI) components from FunctionBuilder. - tarunon/UIViewBuilder
Avatar
kateinoigakukun 06-Jan-20 02:21 PM
あ、わかった
Avatar
tarunon 06-Jan-20 02:21 PM
天才か
Avatar
kateinoigakukun 06-Jan-20 02:22 PM
これどっちもWT経由の呼び出しになってないんじゃ無いですかね
Avatar
tarunon 06-Jan-20 02:22 PM
デバッガでwt確認済みです
Avatar
kateinoigakukun 06-Jan-20 02:24 PM
Witness methodはテーブルに乗ってなくても経由される気がします
プロトコルの要求に_differenceが無いのでWTに乗らず、静的にディスパッチされてるんじゃ無いですかね
Avatar
tarunon 06-Jan-20 02:26 PM
🤔
ベースになってる_Componentの要求なんですよね
Avatar
kateinoigakukun 06-Jan-20 02:27 PM
本当だ…そしたら全く分からなくなった…
Avatar
tarunon 06-Jan-20 02:28 PM
ここで1時間ぐらいハマってしまった。AnyEquatable2020を使うプランに切り替えます。偽equalityそこら中で使うので。
Avatar
kateinoigakukun 06-Jan-20 02:29 PM
時間ある時にちゃんとみます 👀 ぼくもこのテクニック使いたいので。
Avatar
tarunon 06-Jan-20 02:30 PM
このコミットはこのまま置いておこう
Avatar
kateinoigakukun 06-Jan-20 02:30 PM
🙏
Avatar
tarunon 06-Jan-20 02:31 PM
もしかしたら、呼び出し時に型を参照できなくなってるかもしれないですね。その場合AnyEquatableでもダメだ (edited)
Avatar
tarunon 06-Jan-20 02:49 PM
@swift-5.1.5
protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } print(AnyEquatable(value: "abc" as Any).isEqual(to: AnyEquatable(value: "abc" as Any)))
Avatar
swift51 BOT 06-Jan-20 02:49 PM
false
Avatar
tarunon 06-Jan-20 02:49 PM
こういうことだと思うんです
やっぱり呼び出し元でEquatableが見えてないとAnyEquatableを作った瞬間にfalse側に倒れちゃいますね。上位から伝播させなければいけない
@swift-5.1.5
protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } func check<T>(lhs: T, rhs: T) -> Bool { AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs)) } print(check(lhs: "test", rhs: "test"))
Avatar
swift51 BOT 06-Jan-20 02:54 PM
false
Avatar
omochimetaru 06-Jan-20 02:59 PM
AnyEquatable<Any>になっちゃってると、Value: Equatableの評価がAnyに対して行われてしまって、
Anyに入ってる実際の値の型では処理されないってこと?
Avatar
tarunon 06-Jan-20 02:59 PM
そうです
Avatar
omochimetaru 06-Jan-20 03:00 PM
なるほど。う~ん、それは正しい挙動だな。
Anyにしまうことで型情報が消去されたと。
Avatar
tarunon 06-Jan-20 03:00 PM
Generics内部でなんでこうなるかは謎だが
Avatar
kateinoigakukun 06-Jan-20 03:00 PM
そうかなるほど
Avatar
tarunon 06-Jan-20 03:01 PM
うわうわうわうわう
@swift-5.1.5
protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } func check<T>(lhs: T, rhs: T) { print(AnyEquatable(value: lhs)) print(AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs))) } func check2(lhs: String, rhs: String) { print(AnyEquatable(value: lhs)) print(AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs))) } check(lhs: "test", rhs: "test") check2(lhs: "test", rhs: "test")
Avatar
swift51 BOT 06-Jan-20 03:01 PM
AnyEquatable<String>(value: "test") false AnyEquatable<String>(value: "test") true
Avatar
tarunon 06-Jan-20 03:01 PM
シュレディンガーの猫みたいな動きをするな
Avatar
omochimetaru 06-Jan-20 03:02 PM
お~
Avatar
tarunon 06-Jan-20 03:02 PM
同じ型なのにwtの参照先が違うのはやばいなw
Avatar
omochimetaru 06-Jan-20 03:02 PM
バグっぽい
Avatar
kateinoigakukun 06-Jan-20 03:02 PM
いやー、これは無理じゃ無いですかねー
Avatar
tarunon 06-Jan-20 03:03 PM
Anyで潰れるのは許せると思うんですが
GenericsでStringが渡ったのに潰れるのは微妙では
AnyEquatable<Any>(value: "test")なら良い
Avatar
kateinoigakukun 06-Jan-20 03:04 PM
checkがWTを受け取るようになってないから現状のABIでは厳しそう
Avatar
tarunon 06-Jan-20 03:04 PM
ふむー
Avatar
omochimetaru 06-Jan-20 03:04 PM
ん?TとしてRuntimeにString.selfは渡ってきていて
String.selfからEquatable conformance for StringのWTはダイナミックに取れない?
そうじゃないのか? AnyEquatable<$T> みたいなものとして静的に解決している?
Avatar
kateinoigakukun 06-Jan-20 03:06 PM
取れることは取れるんですけど、本来それは呼び出し元でコンフォーマンスを取得してcheckに渡す形になるはずで、checkの中で任意の型に対して毎回コンフォーマンスを取得するのはコストが大きい気がします
Avatar
omochimetaru 06-Jan-20 03:06 PM
クエリ自体でキャッシュされるはず
Avatar
kateinoigakukun 06-Jan-20 03:07 PM
それはそうですけど…
Avatar
tarunon 06-Jan-20 03:07 PM
とりあえずバグレポいってみよう
Avatar
kateinoigakukun 06-Jan-20 03:07 PM
そうですね
Avatar
omochimetaru 06-Jan-20 03:07 PM
dup探すのむずそう。
Avatar
tarunon 06-Jan-20 03:07 PM
きびしーね
Avatar
omochimetaru 06-Jan-20 03:08 PM
まあとりあえず現状のふるまいとしては
extensionの解決は一般のTでコンパイル時に確定しているってことね
これそうか、
func check3<T: Equatable>(...) {}
Avatar
tarunon 06-Jan-20 03:09 PM
そうです
Avatar
omochimetaru 06-Jan-20 03:09 PM
↑これも作っておけばよいのね
Avatar
kateinoigakukun 06-Jan-20 03:09 PM
そうそう
Avatar
tarunon 06-Jan-20 03:09 PM
まあそこをオーバーロードで解決が丸いかな
因みに
Avatar
omochimetaru 06-Jan-20 03:09 PM
めんどいけど対応はできるね
Avatar
tarunon 06-Jan-20 03:09 PM
挙動からの推測ですが、おもちさんのextensionを使った擬似open existentialで
この壁を突破できる予感があります。少なくともそうでないと、私のコードが動いてる理由がよくわからない。
Avatar
omochimetaru 06-Jan-20 03:10 PM
たしかに。
Avatar
tarunon 06-Jan-20 03:10 PM
今回消滅を起こしてる箇所はわかっていて
そこをなんとかできないかこれから試す
あ、擬似open existential、これでもかというほど役に立っています。ありがとう
Avatar
omochimetaru 06-Jan-20 03:11 PM
ただの
Anyにextensionはやせたっけ
Avatar
tarunon 06-Jan-20 03:11 PM
だめ
Avatar
omochimetaru 06-Jan-20 03:11 PM
じゃあだめだ
疑似ってか本物のopenだと思う (edited)
Avatar
tarunon 06-Jan-20 03:11 PM
Equatable確認したいよprotocolを作れば良い
Avatar
omochimetaru 06-Jan-20 03:12 PM
ああそっか。
便利だよね
知らないとかけないコード結構ある
僕が呼び方を名付けるとしたら、existential extensionによる間接open、とかかな
Avatar
tarunon 06-Jan-20 03:13 PM
あ、ダメだった
@swift-5.1.5
protocol AnyEquatableBase { associatedtype Value var value: Value { get } func isEqual(to other: Self) -> Bool } extension AnyEquatableBase { func isEqual(to other: Self) -> Bool { false } } extension AnyEquatableBase where Value: Equatable { func isEqual(to other: Self) -> Bool { value == other.value } } protocol MaybeEquatable { } extension MaybeEquatable { func isEqual(to other: Self) -> Bool { AnyEquatable(value: self).isEqual(to: AnyEquatable(value: other)) } } struct AnyEquatable<T>: AnyEquatableBase { var value: T } extension String: MaybeEquatable {} func check<T: MaybeEquatable>(lhs: T, rhs: T) { print(lhs.isEqual(to: rhs)) } func check2(lhs: String, rhs: String) { print(AnyEquatable(value: lhs), AnyEquatable(value: lhs).isEqual(to: AnyEquatable(value: rhs))) } check(lhs: "test", rhs: "test") check2(lhs: "test", rhs: "test")
Avatar
swift51 BOT 06-Jan-20 03:14 PM
false AnyEquatable<String>(value: "test") true
Avatar
tarunon 06-Jan-20 03:14 PM
だめです
Avatar
kateinoigakukun 06-Jan-20 03:16 PM
Selfの型が静的に決まっちゃうからダメなのかー
Avatar
tarunon 06-Jan-20 03:17 PM
雑に探した感じ特に無さそうなのでダブってたら閉じてもらおう
Avatar
omochimetaru 06-Jan-20 03:18 PM
なんか俺が思ったのと違うな ちょっとやってみる
あー、事前に対象の型を extension Cat: MaybeEquatable {} しておかないといけない。
Avatar
tarunon 06-Jan-20 03:25 PM
ん、してあると思う
あ、Tにってことか!
Avatar
omochimetaru 06-Jan-20 03:26 PM
AnyEquatableのTに制約として T: MaybeEquatable した上で
Cat: MaybeEquatable みたいな。
Avatar
tarunon 06-Jan-20 03:26 PM
おk理解
しかしそこまで行くと使いたいかっていうとウーンだな
Avatar
omochimetaru 06-Jan-20 03:27 PM
うむ。
結局 check3 をオーバーロードするか
Avatar
tarunon 06-Jan-20 03:27 PM
MaybeEquatableをpublicにしなきゃいけない、バッちすぎ
Avatar
omochimetaru 06-Jan-20 03:27 PM
扱いたい型全部にそれを付けるかになる
use-site overloadかtype-decl site conformanceか、みたいな・・・
Avatar
tarunon 06-Jan-20 03:29 PM
use-siteじゃなくても、型の要求する関数の宣言箇所でEquatableを条件にしたWTがあれば、一応open existentialで動く。私のコードはそれでもって動いてるからなぁ (edited)
Avatar
omochimetaru 06-Jan-20 03:32 PM
制約のないT から実行時に T: P で分岐する事は不可能なのかな? (edited)
Avatar
tarunon 06-Jan-20 03:33 PM
それは可能
上の方に貼った動いてる方のコード、がそれを実現してる
あー
正確にはComponentのProtocolでは縛られてるから
関係のない型で縛る必要はあると思う
Avatar
omochimetaru 06-Jan-20 03:34 PM
どれだ
ああ
そうね、なにか引っ掛けるためのプロトコルが必要
なにもない T だったらってこと。
やはりRuntime APIを使う必要があるな
Avatar
tarunon 06-Jan-20 03:35 PM
無から有は作れないか〜
Avatar
omochimetaru 06-Jan-20 03:36 PM
// witness_table* swift_conformsToProtocol(type*, protocol*);
ただこれ使ってもそこから先も工夫が必要なんだよな、witness tableで、どうすんのっていう
Avatar
tarunon 06-Jan-20 03:36 PM
これが使えたところで==の呼び出しが叶わなければ無駄
今回のハックの激アツだったところは無から==が呼び出せる可能性があったからなのだ
Avatar
omochimetaru 06-Jan-20 03:37 PM
witness tableから static funcを引っ張ってこないといけない
つまりwitness method callの自作
いや、なんかerasureを用意してそれのinit呼び出しにすればいいのか まあそれもgeneric method callですが
厳しいな、swift calling conventionがC言語から使えないから
マシンごとにアセンブリでレジスタ登録して呼び出さないとダメそう
うーん
swiftselfもswifterrorも関係ないからC言語で辻褄合わせた関数シグネチャ作ったらABIが合う気がしなくもない
Avatar
tarunon 06-Jan-20 03:48 PM
うーんBaseProtocolの中にこっそり混ぜる分にはアリな気がしてきた>MaybeEquatable
ちょっとこれ無しでValue:Equatableハックは複雑な型だと厳しすぎる
どうせprotocolで引っ掛けてるならやってること一緒なんだよな
Avatar
tarunon 06-Jan-20 04:05 PM
再現できなかった😞
全てがGenericsで渡ってるとうまく動く、一回でもExistentialに墜ちるとダメっぽい。じゃあ私のコードはなぜ動いていたの
Avatar
tarunon 06-Jan-20 05:11 PM
解決しました。 Existentialになった型自身でWTの探索をさせるのがポイントだったようです。 一般化した実装をつくりました。 https://gist.github.com/tarunon/85bdeccf8bc8f44b7b27d4974e0a843f
GitHub Gist: instantly share code, notes, and snippets.
Avatar
omochimetaru 07-Jan-20 01:16 AM
これだと、AnyEquatableのinitのところで、E:Equatableの制約を静的に見てるから
結局制約のないTのパターンのcheckだと無理なのは一緒に見える
Avatar
tarunon 07-Jan-20 01:17 AM
それはそう、なのでMaybeEquatableを外側に置いて、そこからAnyEquatableを生成する事でその課題をクリアしている
Avatar
omochimetaru 07-Jan-20 01:18 AM
ああ、出発点(ユーザーが触る方)はそっちか。
これは、extensionのisEqualの中からだと
動的な判定でSelf:Equatableのwhereの方を呼び出せるってこと?
Avatar
tarunon 07-Jan-20 01:19 AM
そういうことです
Avatar
omochimetaru 07-Jan-20 01:20 AM
よし、理解あってた
Avatar
tarunon 07-Jan-20 01:20 AM
公開するProtocolのベースにMaybeEquatableを使う事で、ユーザーサイドで付与したEquatableを使って動作を切り替えることができる
Avatar
omochimetaru 07-Jan-20 01:20 AM
やはりexistential extension openは魔法的だ
Avatar
tarunon 07-Jan-20 01:20 AM
魔法ですねぇ
しかもこれ、ちょっと作り方違うと動かないので
Avatar
omochimetaru 07-Jan-20 01:34 AM
あ〜 簡単にしようとしたら、 MaybeEquatableにSelfが入って ダウンキャストできなくなったw
Avatar
tarunon 07-Jan-20 01:34 AM
でしょw
Avatar
omochimetaru 07-Jan-20 01:34 AM
でももうちょっときれいにできる気がするなあ
Avatar
tarunon 07-Jan-20 01:34 AM
AnyEquatableとMaybeEquatableの関係が、この間Twitterで言ってた逆転させるprotocolのテクニックです
型消去を使ってprotocolの宣言を外しつつwtを別の場所に移動させる
Avatar
omochimetaru 07-Jan-20 01:56 AM
GitHub Gist: instantly share code, notes, and snippets.
Avatar
tarunon 07-Jan-20 01:57 AM
私のやつ、public protocolにwtを乗せたくなかったからわけていたのだ
Avatar
omochimetaru 07-Jan-20 02:01 AM
どういう意味?
Avatar
tarunon 07-Jan-20 02:02 AM
_isEqualとか__isEqualをユーザーサイドで実装したり呼び出したり、を出来ないようにしたかった
Avatar
omochimetaru 07-Jan-20 02:02 AM
asAnyEquatable().isEqual()が呼び出せるのは良いのか
Avatar
tarunon 07-Jan-20 02:02 AM
そこinternalにできるよ
Avatar
omochimetaru 07-Jan-20 02:03 AM
あ〜
Avatar
tarunon 07-Jan-20 02:03 AM
AnyEquatableの存在だけをpublicにして、他のすべてを封印できる
Avatar
omochimetaru 07-Jan-20 02:03 AM
func anyIsEqual と asAnyEquatable だけが見えてて
Avatar
tarunon 07-Jan-20 02:03 AM
そういうテクニックですだ
そうそう
Avatar
omochimetaru 07-Jan-20 02:03 AM
AnyEquatableの機能は使えない
って状態にできるのね。
Avatar
tarunon 07-Jan-20 02:04 AM
確かにもうちょい減らせる気がしてきたな
Avatar
tarunon 07-Jan-20 02:11 AM
いらんprotocol減らしてあとは比較対象の方は値しか使わない(関数は利用されてない)のでopenしなくて良さそう
Avatar
omochimetaru 07-Jan-20 02:14 AM
as? T でいいよね。 (edited)
Avatar
tarunon 07-Jan-20 02:14 AM
そうね
Avatar
omochimetaru 07-Jan-20 02:27 AM
う〜ん不思議だ、継承boxを作らないでやろうとすると何かしら詰まる。
Avatar
tarunon 07-Jan-20 02:29 AM
継承boxが==をキャプチャするのがミソと思われる
Avatar
omochimetaru 07-Jan-20 02:38 AM
できた。 MaybeEquatable.isEqual(to)と MaybeEquatable.eraseToOpaqueEquatable()と ErasedOpaqueEquatableしか露出していない。 ErasedOpaqueEquatableのメンバは全部隠した。 (edited)
Avatar
tarunon 07-Jan-20 02:39 AM
めっちゃいい
Avatar
omochimetaru 07-Jan-20 02:39 AM
erasureは外側はなくして継承Boxそのままにした。 (edited)
Avatar
tarunon 07-Jan-20 02:39 AM
そうか、どうせ公開しないなら外側が要らなくなるのね
Avatar
omochimetaru 07-Jan-20 02:39 AM
ErasedOpaqueEquatableもpublicだけどopenじゃないからユーザー継承もできないし。
Avatar
tarunon 07-Jan-20 03:18 AM
継承消せたw
@swift-5.1.5
public protocol MaybeEquatable { func eraseToOpaqueEquatable() -> ErasedOpaqueEquatable } extension MaybeEquatable { public func isEqual(to other: Any) -> Bool { eraseToOpaqueEquatable().isEqualTo(other) } } extension MaybeEquatable { public func eraseToOpaqueEquatable() -> ErasedOpaqueEquatable { ErasedOpaqueEquatable() } } extension MaybeEquatable where Self: Equatable { public func eraseToOpaqueEquatable() -> ErasedOpaqueEquatable { ErasedOpaqueEquatable(value: self) } } public struct ErasedOpaqueEquatable { var isEqualTo: (Any) -> Bool init() { isEqualTo = { _ in false } } init<T: Equatable>(value: T) { isEqualTo = { value == $0 as? T } } } // end user interface public func anyIsEqual(_ a: Any, _ b: Any) -> Bool { guard let a = a as? MaybeEquatable else { return false } return a.isEqual(to: b) } // you need to mark your type extension String: MaybeEquatable {} print(anyIsEqual("str", "str")) // => true print(anyIsEqual({}, {})) // => false
Avatar
omochimetaru 07-Jan-20 03:18 AM
おお
Avatar
swift51 BOT 07-Jan-20 03:18 AM
true false
Avatar
tarunon 07-Jan-20 03:18 AM
これが一番短いと思います
Avatar
omochimetaru 07-Jan-20 03:19 AM
あ〜wクロージャねw
確かにクロージャってそもそもが型Fに対して
値で実装を分けてるから
ベースクロージャ型と、個別のクロージャ式に対応する型の
アドホックな継承関係なんだよな
Avatar
tarunon 07-Jan-20 03:19 AM
うむ
Avatar
omochimetaru 07-Jan-20 03:20 AM
今回はどうせ処理を切り分けたいだけの継承だからクロージャでもいいか。 強いて言えば若干デバッグしづらいかな。
Avatar
tarunon 07-Jan-20 03:20 AM
まあここをデバッグする事はあんまり無さそう
Avatar
omochimetaru 07-Jan-20 03:21 AM
そうすると、ErasedOpaqueEquatableもなくして、 (Any)->Bool を返すのもありだな
Avatar
tarunon 07-Jan-20 03:21 AM
お、なるほど
Avatar
omochimetaru 07-Jan-20 03:21 AM
func partialApplySelfToIsEqual() -> (Any) -> Bool
Avatar
tarunon 07-Jan-20 03:21 AM
ヤベェ関数が生えたw
Avatar
omochimetaru 07-Jan-20 03:22 AM
まあユーザーにこれが見えるのと、ErasedOpaqueEquatableが見えるの、どっちが良いかって択だな
Avatar
tarunon 07-Jan-20 03:23 AM
typealiasにして誤魔化すのはどうだろう
typealias PartialAppySelfToIsEqual = (Any)->Bool
Avatar
omochimetaru 07-Jan-20 03:26 AM
ユーザーからするとErasedOpaqueEquatableはその先のisEqualの呼び出しができないけど
typealias PartialAppySelfToIsEqualは、関数としての呼び出しができるという意味では
露出はやっぱり増えてるね
Avatar
tarunon 07-Jan-20 03:26 AM
確かに
コードは圧倒的に短いな、4ブロックだ
Avatar
omochimetaru 07-Jan-20 03:27 AM
そういう意味ではさっきのtarunonのやつが露出最小の場合の実装最小な気がする
Avatar
tarunon 07-Jan-20 03:27 AM
まあでも実質的にisEqual(to:)呼ぶのと変わらんけ
Avatar
omochimetaru 07-Jan-20 03:27 AM
露出をちょっと許すなら partialApplySelfToIsEqualだと思う
うん。そうね。
Avatar
tarunon 07-Jan-20 03:27 AM
実行時に軽い方でもいい気がする
ヘッダーから見える世界はこう
綺麗では
Avatar
omochimetaru 07-Jan-20 03:28 AM
typealiasなのも見えるでしょ?
Avatar
tarunon 07-Jan-20 03:28 AM
typealiasも見えてるけど
まあ許せる範囲かな
しかしこのテクニック凄いね、今までできなかったことが出来るようになった
Avatar
omochimetaru 07-Jan-20 03:30 AM
まあMaybeEquatableでマーキングするという作業は残っちゃってるけどね
実行時ダウンキャストで where を復元できるのは面白い。
Avatar
tarunon 07-Jan-20 03:30 AM
protocol conformingを通してexistentialを作れないprotocolへのダウンキャストを実装する、という手法かな
open existentialと並ぶ革命だわ
Avatar
omochimetaru 07-Jan-20 03:31 AM
そうだね、PATへのダウンキャストを普通のprotocolを一回挟むとできる
業務だと、
レスポンスの型を登録しておいて
レスポンスの中にあるtypeってフィールドを見て、対応するレスポンスの型を動的にdecodeする、
みたいなパターンで似たような事をしていた
リクエストの型のassociatedtypeからレスポンスの型をジェネリクスで引っ張るのが一般的だと思うんだけど
正常系のレスポンスはそれで良いとして、エラーレスポンスも型付けしたいからそうしてた
Avatar
tarunon 07-Jan-20 03:34 AM
APIの話だと私の書いたコードだとエラーもあらかじめ型付けしてあってレスポンス同様にデコードしてたな
Avatar
omochimetaru 07-Jan-20 03:35 AM
普通にやるとエラーをデコードしてる処理を、エラーの種類を足すごとに追加するか、 リクエストに対して固定のエラー型にならない?
Avatar
tarunon 07-Jan-20 03:36 AM
protocol Request { associatedtype Response associatedtype Error }
Avatar
omochimetaru 07-Jan-20 03:36 AM
そうよね。
Avatar
tarunon 07-Jan-20 03:36 AM
これで事足りる気がするけど
Avatar
omochimetaru 07-Jan-20 03:37 AM
let possibleErrorTypes: [APIResponseErrorProtocol.Type] = [LoginError.self, ValidationError.self, ...]
こういう感じに配列で登録しておいてどんな型のエラーも飛ばせるようにした感じ。
Avatar
tarunon 07-Jan-20 03:37 AM
ほー
enumじゃだめなん
Avatar
omochimetaru 07-Jan-20 03:38 AM
enumにした場合、結局、そのenumのdecodeを書くところで
JSONのtypeフィールドの文字列を見て、switch-caseで
type文字列ごとに対応するcaseをdecodeするって処理を
書く部分が出てくるでしょ?
Avatar
tarunon 07-Jan-20 03:39 AM
配列だと出ない?
Avatar
omochimetaru 07-Jan-20 03:39 AM
でない。
Avatar
tarunon 07-Jan-20 03:39 AM
🤔
Avatar
omochimetaru 07-Jan-20 03:39 AM
enumだと、
普通にやるとエラーをデコードしてる処理を、エラーの種類を足すごとに追加するか、 リクエストに対して固定のエラー型にならない?
↑で書いたように、エラーの種類を足すごとに case を書かないといけない
配列に入れておいて、
protocol APIResponseErrorProtocol: Decodable { static var typeName: String { get } }
↑こうしておいて、
あとはループしながらtypeNameの対応がみつかったらDecodableでdecode
って形にすると、 エラーの型を定義して、possibleErrorTypes配列にメタタイプを追加していくだけで
decodeのcaseの追加はしなくて良くなる。
Avatar
tarunon 07-Jan-20 03:41 AM
そうすると取り出す側はキャストにならない?
Avatar
omochimetaru 07-Jan-20 03:41 AM
取り出す側はキャストになる。
Avatar
tarunon 07-Jan-20 03:41 AM
Error型だから別にいいやって感じか
Avatar
omochimetaru 07-Jan-20 03:41 AM
でもそれは、 do { } catch { } してるとき、いつもそうだから。
てか、結局の所throwすることになって、画面レベルの 根っこのcatchで分岐する感じ。
エラーレスポンスがそのままアプリの中のエラーとしてthrowされてくる状態。
Avatar
tarunon 07-Jan-20 03:42 AM
なるほどね
Avatar
omochimetaru 07-Jan-20 03:42 AM
Error型だから別にいいやって感じか
そういうことやね
(edited)
Avatar
tarunon 07-Jan-20 03:43 AM
私が書いたのはAPIの関数の返り値はAsync<Result<T,E>>だから、型がしっかりしてるモチベが高いから
あとエンドポイントごとにエラー型を明示的に定義したいモチベもあったのでそういう作りになっていたのだ
enumでもデコード処理をループで書くのは昔作ったから、それでもいい気はしたけど、まあ色々根底が違いそうである
Avatar
omochimetaru 07-Jan-20 03:46 AM
enumでもデコード処理をループで書く
このケースで同じことをやってそうな気がする
Avatar
tarunon 07-Jan-20 03:47 AM
そんな気はするね
今回の価値はextension Tと、extension T where Self: Uが、きちんと期待通りに動くケースを一般化できたことだな
Avatar
omochimetaru 07-Jan-20 03:49 AM
それで、そのループするために、メタタイプを登録していくと、 要素が APIResponseErrorProtocol.Type になるから、 existential openを使わないと init(from decoder: Decoder) が呼べないという話
Avatar
tarunon 07-Jan-20 03:50 AM
なるほどね
Avatar
omochimetaru 07-Jan-20 03:51 AM
今回の価値はextension Tと、extension T where Self: Uが、きちんと期待通りに動くケース
そうね
protocol requirementsにエントリがあってwitness tableに載ってると、 existential extensionのselfからのメソッド呼び出しでディスパッチできる。
Avatar
tarunon 07-Jan-20 03:55 AM
try swiftのltにもっていこうかしら、このサイズなら収まりそう
Avatar
omochimetaru 07-Jan-20 03:59 AM
Equatableにダウンキャストできないよね、ってところから流れで行けばまとまりそう
ただexistential openが結構深いトリックであるってことはスルーされそうだ
Avatar
tarunon 07-Jan-20 04:01 AM
聴衆はそもそもGenericsとExistentialの違いもアヤフヤな人が多い想定なので、敢えてそこは解説しないでいいと思う
Avatar
omochimetaru 07-Jan-20 04:03 AM
できることの結果だけ話すってことね。
Avatar
tarunon 07-Jan-20 04:04 AM
条件と結果、一般化できるぞいというところまでだな。
Avatar
omochimetaru 07-Jan-20 04:04 AM
たしかにタルノンが発表する時ってそういう構成の事が多いな
Avatar
tarunon 07-Jan-20 04:04 AM
いやだって…
Avatar
omochimetaru 07-Jan-20 04:04 AM
いやいや・・・
Avatar
kateinoigakukun 07-Jan-20 12:01 PM
Contribute to kateinoigakukun/AnyEquatable development by creating an account on GitHub.
SPMがCとSwiftの混じったターゲットを作れないので微妙にシンボルが公開されちゃってますが、手でリンクすればisEqualだけ公開するようにできるはず
Contribute to kateinoigakukun/AnyEquatable development by creating an account on GitHub.
Avatar
tarunon 07-Jan-20 12:20 PM
すごww
C経由でSwiftRuntimeを無理やりこねくり回すの、禁断の果実感あって良いですね
Avatar
kateinoigakukun 07-Jan-20 12:26 PM
ミソはwitness methodの呼び出しをSwift側に移譲してる部分です
Avatar
tarunon 07-Jan-20 12:26 PM
これはC部分はどうしてもSwiftだとかけない感じですか?
Avatar
kateinoigakukun 07-Jan-20 12:27 PM
書けそう!
Avatar
tarunon 07-Jan-20 12:27 PM
書けない理由が特に無さそうに見えたので
Avatar
kateinoigakukun 07-Jan-20 12:27 PM
最初はもうちょっと込み入ったことをしようとしてたんですけど結局シンプルにできたのでフルSwiftで書けそう
あー、フルは無理でした
😞 1
ProtocolDescriptorをシンボル経由で抜いてるんですけど、そこで@_silgen_nameが使えなかった…
Avatar
tarunon 07-Jan-20 12:30 PM
なるほど
Avatar
kateinoigakukun 07-Jan-20 12:30 PM
いや、dlsymすればいいのか (edited)
Avatar
tarunon 07-Jan-20 12:31 PM
dlsymはXcode環境下で謎に動かない場合があるので
動くかチェックは必要そう
動かない場合も退避先にMachO使えるし何とかなるんじゃないかな
Avatar
kateinoigakukun 07-Jan-20 01:13 PM
Contribute to kateinoigakukun/AnyEquatable development by creating an account on GitHub.
Swift関数にメタタイプとWTを差し込むためにはC側から呼んでやらないとダメなんですよねー
Avatar
omochimetaru 07-Jan-20 01:21 PM
あれ、やろうと思ってたらもうできちゃった?
Avatar
tarunon 07-Jan-20 01:22 PM
@convention(c)をつけた関数ポインタの首を挿げ替えて無理やりコールは出来ないかな
Avatar
kateinoigakukun 07-Jan-20 01:29 PM
import Foundation let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: -2) @_silgen_name("foo") func foo() {} let fooPtr = { dlsym(RTLD_DEFAULT, "foo")!.assumingMemoryBound(to: (() -> Void).self) }() fooPtr.pointee
これがクラッシュするんですよね、デリファレンスした瞬間にbad accessになる (edited)
@convention(c)どこにもつけられなくて困った
Avatar
norio_nomura 08-Jan-20 09:07 AM
こんな感じにすると@convention(c)使える。
import Foundation public func isEqual(_ lhs: Any, _ rhs: Any) -> Bool { let lhsType = type(of: lhs) let rhsType = type(of: rhs) guard lhsType == rhsType else { return false } guard let witnessTable = swift_conformsToProtocol(lhsType, EquatableProtocolDescriptor) else { return false } let theType = unsafeBitCast(lhsType, to: UnsafeRawPointer.self) return withUnsafePointer(to: lhs) { lhsPtr in withUnsafePointer(to: rhs) { rhsPtr in AnyEquatable_internalIsEqual(lhsPtr, rhsPtr, theType, witnessTable) } } } @_silgen_name("swift_conformsToProtocol") func swift_conformsToProtocol(_: Any.Type, _: UnsafeRawPointer) -> UnsafeRawPointer? func load<T>(symbol: String) -> T { if let sym = dlsym(dlopen(nil, RTLD_LAZY), symbol) { return unsafeBitCast(sym, to: T.self) } let errorString = String(validatingUTF8: dlerror()) fatalError("Finding symbol \(symbol) failed: \(errorString ?? "unknown error")") } let AnyEquatable_internalIsEqual: @convention(c) (UnsafeRawPointer, UnsafeRawPointer, UnsafeRawPointer, UnsafeRawPointer) -> Bool = load(symbol: "AnyEquatable_internalIsEqual") let EquatableProtocolDescriptor: UnsafeRawPointer = load(symbol: "$sSQMp") @_silgen_name("AnyEquatable_internalIsEqual") func _internalIsEqual<T: Equatable>(_ lhs: T, rhs: T) -> Bool { return lhs == rhs }
(edited)
しかし、LinuxだとシンボルAnyEquatable_internalIsEqualを見つけられないな。
Avatar
kateinoigakukun 08-Jan-20 12:38 PM
なるほどなるほど
Linuxでシンボル見つけられないのはなんでだろう…
そもそも、フルSwiftで書くためにわざわざダイナミックリンクするのは微妙な気がしてきた (edited)
Avatar
norio_nomura 08-Jan-20 01:18 PM
面白いけど、実際に使おうとは思えないですね。
Avatar
norio_nomura 08-Jan-20 11:33 PM
swift52ボット、新規で作るか、swift40ボットを動かしてるHeroku環境を流用してしまおうか、迷う。
Avatar
Kishikawa Katsumi 09-Jan-20 03:46 AM
どういう違いがあるんですか?
Avatar
norio_nomura 09-Jan-20 04:00 AM
一つのボットに一つのherokuアカウントを使う構成なのです。
流用すればアカウントを増やさずに済む。swift40ボットは無くなるけど。
ボットを使う側に対しては「swift40ボットにまだ生き残って欲しいか?」という質問になりますね。
Avatar
tarunon 09-Jan-20 04:07 AM
4系は4.2が生きていれば良さそうに思えます。Xcodeもそうだし。
Avatar
Kishikawa Katsumi 09-Jan-20 04:08 AM
あ、そういう意味ですか。なんとなく残っていたら便利かなと思います。
Avatar
norio_nomura 09-Jan-20 04:11 AM
追加するかな。
Avatar
norio_nomura 09-Jan-20 05:17 AM
@swift-5.2.5 -version
Avatar
swift52 BOT 09-Jan-20 05:17 AM
Swift version 5.2-dev (Swift 74df1132af) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 09-Jan-20 05:26 AM
@swift-5.2.5
struct SimpleCallable { func callAsFunction(_ x: Float) -> Float { return x } } let foo = SimpleCallable() print(foo(1)) print(foo(foo(1)))
Avatar
swift52 BOT 09-Jan-20 05:26 AM
1.0 1.0
Avatar
omochimetaru 10-Jan-20 10:06 AM
@swift-nightly
func f(g: @escaping () -> Void) { } class C { var name = "tama" func main() { f { [self] in print(name) } } }
Avatar
swiftNightly BOT 10-Jan-20 10:06 AM
no output
Avatar
omochimetaru 10-Jan-20 10:07 AM
@swift-5.2.5
func f(g: @escaping () -> Void) { } class C { var name = "tama" func main() { f { [self] in print(name) } } }
Avatar
swift52 BOT 10-Jan-20 10:07 AM
exit status: 1 with stderr:
<stdin>:7:13: error: reference to property 'name' in closure requires explicit 'self.' to make capture semantics explicit print(name) ^ self. <stdin>:6:10: warning: capture 'self' was never used f { [self] in ^
Avatar
omochimetaru 10-Jan-20 10:08 AM
Update the lookup logic for closures to allow resolution of implicit self to resolve to any direct captures of self (e.g. { [self] in ... }) in closures. Also introduce new diagnostic logic to sugg...
Avatar
Kishikawa Katsumi 10-Jan-20 05:05 PM
@swiftbot
#if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Avatar
swiftbot BOT 10-Jan-20 05:05 PM
Author icon kishikawakatsumi
#if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Version:
swift-5.1.3-RELEASE
Output:
Running on Linux
Error:
Avatar
Kishikawa Katsumi 10-Jan-20 05:06 PM
@swiftbot --platform=mac
#if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Avatar
swiftbot BOT 10-Jan-20 05:06 PM
Author icon kishikawakatsumi
#if os(Linux) print("Running on Linux") #else print("Running on macOS") #endif
Version:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin19.2.0
Output:
Running on macOS
Error:
Avatar
Kishikawa Katsumi 10-Jan-20 05:06 PM
とりあえずMac上の実行サポートしました。Macで動作が変わるコードってどんなんでしたっけ?
Avatar
omochimetaru 10-Jan-20 06:28 PM
@swiftbot --platform=mac
class C {} let a = C.self as AnyObject
Avatar
swiftbot BOT 10-Jan-20 06:28 PM
Author icon omochimetaru
class C {} let a = C.self as AnyObject
Version:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin19.2.0
Output:
Error:
Avatar
omochimetaru 10-Jan-20 06:28 PM
@swiftbot --platform=linux
class C {} func f(_ a: AnyObject) {} f(C.self)
(edited)
Avatar
swiftbot BOT 10-Jan-20 06:28 PM
(edited)
Author icon omochimetaru
class C {} func f(_ a: AnyObject) {} f(C.self)
Version:
swift-5.1.3-RELEASE
Output:
Error:
/usercode/main.swift:3:3: error: argument type 'C.Type' does not conform to expected type 'AnyObject' f(C.self) ^
Avatar
omochimetaru 10-Jan-20 06:30 PM
@swiftbot --platform=mac
class C {} func f(_ a: AnyObject) {} f(C.self)
Avatar
swiftbot BOT 10-Jan-20 06:30 PM
Author icon omochimetaru
class C {} func f(_ a: AnyObject) {} f(C.self)
Version:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin19.2.0
Output:
Error:
Avatar
omochimetaru 10-Jan-20 06:30 PM
おーmacだ
Avatar
nanasi 15-Jan-20 08:48 AM
@swiftbot
struct Example { var value: some Equatable { 1 } } struct Foo { typealias Body = @_opaqueReturnTypeOf("$s4main7ExampleV5valueQrvp", 0) 🦸 } print(Foo.Body.self)
Avatar
swiftbot BOT 15-Jan-20 08:48 AM
nanasi
struct Example { var value: some Equatable { 1 } } struct Foo { typealias Body = @_opaqueReturnTypeOf("$s4main7ExampleV5valueQrvp", 0) 🦸 } print(Foo.Body.self)
Version:
swift-5.1.3-RELEASE
Output:
Int
Error:
Avatar
nanasi 16-Jan-20 04:57 AM
@swiftbot
@propertyWrapper struct Generics<T> { var wrappedValue: T { 100 as! T } init(_ type: T.Type = T.self) {} } struct Example { @Generics(Int.self) var value } print(Example().value)
Avatar
swiftbot BOT 16-Jan-20 04:57 AM
nanasi
@propertyWrapper struct Generics<T> { var wrappedValue: T { 100 as! T } init(_ type: T.Type = T.self) {} } struct Example { @Generics(Int.self) var value } print(Example().value)
Version:
swift-5.1.3-RELEASE
Output:
100
Error:
Avatar
nanasi 16-Jan-20 04:58 AM
@swiftbot
@propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics var value } print(Example().value)
Avatar
swiftbot BOT 16-Jan-20 04:58 AM
nanasi
@propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics var value } print(Example().value)
Version:
swift-5.1.3-RELEASE
Output:
Error:
/usercode/main.swift:7:21: error: type annotation missing in pattern @NoGenerics var value ^
Avatar
nanasi 17-Jan-20 07:04 AM
@swiftbot
@propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics() var value } print(Example().value)
Avatar
swiftbot BOT 17-Jan-20 07:04 AM
nanasi
@propertyWrapper struct NoGenerics { var wrappedValue: Int { 100 } } struct Example { @NoGenerics() var value } print(Example().value)
Version:
swift-5.1.3-RELEASE
Output:
100
Error:
Avatar
nanasi 17-Jan-20 07:05 AM
明示的なイニシャライザ呼び出しがあると型を省略できるのか🤔
Avatar
omochimetaru 17-Jan-20 07:06 AM
ww
微妙な推論器の走らせ方の違いが引き起こしてそうだ。
Avatar
freddi 20-Jan-20 01:42 AM
@swift-5.1.5
class Cat { private let _bow: String = "にゃー" var bow: String { get { _bow } _modify { yield &_bow } } } var tama = Cat() tama.a = "わん" print(tama.a)
Avatar
swift51 BOT 20-Jan-20 01:42 AM
exit status: 1 with stderr:
<stdin>:8:20: error: cannot assign to property: '_bow' is a 'let' constant yield &_bow ^~~~ <stdin>:2:13: note: change 'let' to 'var' to make it mutable private let _bow: String = "にゃー" <stdin>:13:6: error: value of type 'Cat' has no member 'a' tama.a = "わん" <stdin>:14:12: error: value of type 'Cat' has no member 'a' print(tama.a) ~~~~ ^
Avatar
freddi 20-Jan-20 01:44 AM
あ、みすってた
@swift-5.1.5
class Cat { let _bow: String = "にゃー" var bow: String { get { _bow } _modify { yield &_bow } } } var tama = Cat() tama.bow = "わん" print(tama.bow)
Avatar
swift51 BOT 20-Jan-20 01:44 AM
exit status: 1 with stderr:
<stdin>:8:20: error: cannot assign to property: '_bow' is a 'let' constant yield &_bow ^~~~ <stdin>:2:5: note: change 'let' to 'var' to make it mutable let _bow: String = "にゃー"
Avatar
freddi 20-Jan-20 01:44 AM
まあそうか
Avatar
freddi 20-Jan-20 01:51 AM
でもこれ僕のプロジェクトだとコンパイルとおってるの不思議だ 見間違えだった (edited)
Avatar
freddi 20-Jan-20 02:00 AM
あ、コンパイルとおった
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15) Target: x86_64-apple-darwin18.6.0
だと
class Neko { private let _bow: String = "にゃん" var bow: String { get { _bow } _modify { yield &bow } } } let cat = Neko() cat.bow = "わん" print(cat.bow)
は通るっぽい、多分もう修正されてるってことかな
Avatar
omochimetaru 20-Jan-20 02:01 AM
それ実行したら無限ループしないのか
Avatar
freddi 20-Jan-20 02:01 AM
あ、たしかに
あ、あんだーばーが抜けてましたね
凡ミスで草ですね
ちゃんとエラーでた、失礼しました 🙇‍♂️ (edited)
Avatar
swift50 BOT 24-Jan-20 03:16 AM
exit status: 1 with stderr:
<stdin>:5:30: error: type 'C2' constrained to non-protocol, non-class type 'Self.X' associatedtype X where C2: X ^
Avatar
norio_nomura 24-Jan-20 03:34 AM
ボットの不調、Herokuのログシステムにも障害が起きてて、不調だった際のログが残ってない。 https://status.heroku.com
Heroku Status provides the current status and incident history report for the Heroku platform.
Avatar
omochimetaru 24-Jan-20 03:34 AM
クラウドレベルでのトラブなのか。
Avatar
norio_nomura 24-Jan-20 03:38 AM
外部へ送ってるログを見ると、swift50ボットだけリクエストを受け付けたログに漏れがある様なので、swift50ボットだけ影響を受けてたぽい。
😮 1
Avatar
norio_nomura 01-Feb-20 05:29 AM
@swift-5.1.5 -version
Avatar
swift51 BOT 01-Feb-20 05:29 AM
Swift version 5.1.4 (swift-5.1.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Kishikawa Katsumi 01-Feb-20 07:33 AM
5.1.4が12時間くらい前にひっそりリリースされてるんですね。
Avatar
norio_nomura 01-Feb-20 09:09 AM
リリースタグがついてからswift.orgに現れるまでは、毎回かなり時間がかかりますね。
Avatar
Kishikawa Katsumi 01-Feb-20 09:12 AM
あら、そうなんですね。
Avatar
norio_nomura 01-Feb-20 09:29 AM
タグが付いたらすぐにswift.orgで公開されるスナップショットと違って、リリースはタグ付けから公開までの時間がまちまちだから、たぶん途中に手作業が入ってる。
Avatar
Kishikawa Katsumi 01-Feb-20 03:15 PM
@swiftbot --version=3.0.1
class Foo { private var fooPrivate = "private property" } extension Foo { func bar() -> String { return fooPrivate } } print(Foo().bar())
Avatar
swiftbot BOT 01-Feb-20 03:15 PM
Author icon kishikawakatsumi
class Foo { private var fooPrivate = "private property" } extension Foo { func bar() -> String { return fooPrivate } } print(Foo().bar())
Version:
swift-3.0.1-RELEASE
Output:
Error:
/usercode/main.swift:7:16: error: 'fooPrivate' is inaccessible due to 'private' protection level return fooPrivate ^ /usercode/main.swift:2:17: note: 'fooPrivate' declared here private var fooPrivate = "private property" ^
Avatar
nanasi 08-Feb-20 06:49 AM
@swift-5.2.5
@dynamicMemberLookup public protocol Entity { associatedtype Identifier associatedtype Props var id: Identifier { get } var props: Props { get set } } extension Entity { public typealias SegFaultHere<T> = T @inlinable public subscript <Value>(dynamicMember keyPath: WritableKeyPath<Props, Value>) -> Value { get { props[keyPath: keyPath] } set { props[keyPath: keyPath] = newValue } } }
Avatar
swift52 BOT 08-Feb-20 06:49 AM
no output
Avatar
nanasi 13-Feb-20 06:25 AM
@swift-5.2.5
protocol CallAsFunction { func callAsFunction() } struct Foo: CallAsFunction { func callAsFunction() { print("foo") } } func call<C: CallAsFunction>(_ caller: C) { caller() } call(Foo())
Avatar
swift52 BOT 13-Feb-20 06:25 AM
foo
Avatar
nanasi 19-Feb-20 05:27 AM
@swiftbot
struct Value: Hashable { let id = 5 } struct Value2: Hashable { let id = 5 func hash(into hasher: inout Hasher) { hasher.combine(id) } } enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(v) case .b(let v): hasher.combine(v) } } } print(5.hashValue) print(Value().hashValue) print(Value2().hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Avatar
swiftbot BOT 19-Feb-20 05:27 AM
nanasi
struct Value: Hashable { let id = 5 } struct Value2: Hashable { let id = 5 func hash(into hasher: inout Hasher) { hasher.combine(id) } } enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(v) case .b(let v): hasher.combine(v) } } } print(5.hashValue) print(Value().hashValue) print(Value2().hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Version:
swift-5.1.3-RELEASE
Output:
-5563881854129666050 -5563881854129666050 -5563881854129666050 1174769019477244301 8537611810857838151 -5563881854129666050 -5563881854129666050
Error:
Avatar
nanasi 19-Feb-20 05:29 AM
@swiftbot
enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(0) hasher.combine(v) case .b(let v): hasher.combine(1) hasher.combine(v) } } } print(5.hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
(edited)
Avatar
swiftbot BOT 19-Feb-20 05:29 AM
(edited)
nanasi
enum EnumValue: Hashable { case a(Int) case b(Int) } enum EnumValue2: Hashable { case a(Int) case b(Int) func hash(into hasher: inout Hasher) { switch self { case .a(let v): hasher.combine(0) hasher.combine(v) case .b(let v): hasher.combine(1) hasher.combine(v) } } } print(5.hashValue) print(EnumValue.a(5).hashValue) print(EnumValue.b(5).hashValue) print(EnumValue2.a(5).hashValue) print(EnumValue2.b(5).hashValue)
Version:
swift-5.1.3-RELEASE
Output:
3666440306759404138 7344323318427966468 4893249820943752864 7344323318427966468 4893249820943752864
Error:
Avatar
norio_nomura 20-Feb-20 02:40 AM
Standard Library Preview Packageをインポートできる様にしました。 @swift-5.1.5 @swift-5.2.5 @swift-nightly
import StandardLibraryPreview var numbers = [10, 12, -5, 14, -3, -9, 15] let negatives = numbers.subranges(where: { $0 < 0 }) print(negatives) numbers.moveSubranges(negatives, to: 0) print(numbers)
https://swift.org/blog/preview-package/
Avatar
swift52 BOT 20-Feb-20 02:40 AM
RangeSet(2..<3, 4..<6) [-5, -3, -9, 10, 12, 14, 15]
Avatar
swift51 BOT 20-Feb-20 02:41 AM
RangeSet(2..<3, 4..<6) [-5, -3, -9, 10, 12, 14, 15]
Avatar
swiftNightly BOT 20-Feb-20 02:41 AM
RangeSet(2..<3, 4..<6) [-5, -3, -9, 10, 12, 14, 15]
Avatar
omochimetaru 20-Feb-20 02:41 AM
おお〜
Avatar
norio_nomura 28-Feb-20 02:21 AM
https://swift.org/blog/argument-parser/ Swift Argument Parserをインポートできるようにしました。 @swift-nightly @swift-5.2.5 - --help
import ArgumentParser struct Repeat: ParsableCommand { @Flag(help: "Include a counter with each repetition.") var includeCounter: Bool @Option(name: .shortAndLong, help: "The number of times to repeat 'phrase'.") var count: Int? @Argument(help: "The phrase to repeat.") var phrase: String } extension Repeat { func run() throws { let repeatCount = count ?? .max for i in 1...repeatCount { if includeCounter { print("\(i): \(phrase)") } else { print(phrase) } } } } Repeat.main()
(edited)
Avatar
swift52 BOT 28-Feb-20 02:21 AM
USAGE: repeat [--include-counter] [--count <count>] <phrase> ARGUMENTS: <phrase> The phrase to repeat. OPTIONS: --include-counter Include a counter with each repetition. -c, --count <count> The number of times to repeat 'phrase'. -h, --help Show help information.
(edited)
Avatar
swiftNightly BOT 28-Feb-20 02:21 AM
USAGE: repeat [--include-counter] [--count <count>] <phrase> ARGUMENTS: <phrase> The phrase to repeat. OPTIONS: --include-counter Include a counter with each repetition. -c, --count <count> The number of times to repeat 'phrase'. -h, --help Show help information.
(edited)
Avatar
norio_nomura 28-Feb-20 02:23 AM
StandardLibraryPreviewと同時にビルドするには下記エラー回避にSE-0226が必要なため、Swift 5.2以降です。
error: multiple targets named 'TestHelpers' in: swift-argument-parser, swift-se0270-range-set
(edited)
Avatar
omochimetaru 10-Mar-20 04:16 AM
@swift-nightly
func f1(apple: Int..., banana: Int) {} f1(apple: 1, 2, banano: 2)
Avatar
swiftNightly BOT 10-Mar-20 04:16 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/Sema/CSSimplify.cpp:704: bool swift::constraints::matchCallArguments(SmallVectorImpl<AnyFunctionType::Param> &, ArrayRef<AnyFunctionType::Param>, const swift::ParameterListInfo &, bool, bool, swift::constraints::MatchCallArgumentListener &, SmallVectorImpl<ParamBinding> &): Assertion `args[fromArgIdx].getLabel().empty()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries 1. Swift version 5.2-dev (LLV
Avatar
omochimetaru 10-Mar-20 04:16 AM
倒した
Avatar
Kishikawa Katsumi 10-Mar-20 05:22 AM
おお〜、おもしろい不具合だ
Avatar
omochimetaru 10-Mar-20 05:23 AM
Xcode11.3とXcode11.4 beta1 , beta3 だと大丈夫だったので割と新しいバグっぽい。 (edited)
Avatar
omochimetaru 14-Mar-20 02:12 PM
@swift-nightly
func f(aa: Int, bb: Int, cc: Int = 0) {} f(bbx: 0)
(edited)
Avatar
swiftNightly BOT 14-Mar-20 02:12 PM
exit status: 1 with stderr:
<stdin>:3:2: error: incorrect argument labels in call (have 'bbx:', expected 'aa:bb:cc:') f(bbx: 0) ^~~~ aa <stdin>:3:3: error: missing argument for parameter 'aa' in call f(bbx: 0) ^ aa: <#Int#>, <stdin>:1:6: note: 'f(aa:bb:cc:)' declared here func f(aa: Int, bb: Int, cc: Int = 0) {} ^
(edited)
Avatar
omochimetaru 14-Mar-20 02:16 PM
@swift-nightly -frontend -typecheck
func f() {}
Avatar
swiftNightly BOT 14-Mar-20 02:16 PM
no output
Avatar
omochimetaru 14-Mar-20 02:17 PM
@swift-nightly -frontend -typecheck -debug-constraints
func f(){} f()
Avatar
swiftNightly BOT 14-Mar-20 02:17 PM
stderr:
---Constraint solving at [<stdin>:2:1 - line:2:3]--- (overload set choice binding $T0 := () -> ()) ---Initial constraints for the given expression--- (call_expr type='()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:3] arg_labels= (declref_expr type='() -> ()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:1] decl=main.(file).f()@<stdin>:1:6 function_ref=single) (tuple_expr type='()' location=<stdin>:2:2 range=[<stdin>:2:2 - line:2:3])) Score: 0 0 0 0 0 0 0 0 0 0 0 0 Contextual Type: <null> Type Variables: $T0 [lvalue allowed] [noescape allowed] as () -> () @ locator@0x8d2bf90 [DeclRef@<stdin>:2:1] $T1 [noescape allowed] as () @ locator@0x8d2bff8 [Call@<stdin>:2:1 -> function result] Active Constraints: Inactive Constraints: Resolved overloads: selected overload set choice f: $T0 == () -> () (found solution 0 0 0 0 0 0 0 0 0 0 0 0) ---Solver statistics--- Total number of scopes explored: 1 Maximum depth reached while exploring solutions: 1 Time: 4.000000e+00ms ---Solution--- Fixed score: 0 0 0 0 0 0 0 0 0 0 0 0 Type variables: $T1 as () @ locator@0x8d2bff8 [Call@<stdin>:2:1 -> function result] $T0 as () -> () @ locator@0x8d2bf90 [DeclRef@<stdin>:2:1] Overload choices: locator@0x8d2bf90 [DeclRef@<stdin>:2:1] with main.(file).f()@<stdin>:1:6 as f: () -> () Constraint restrictions: Disjunction choices: ---Type-checked expression--- (call_expr type='()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:3] arg_labels= (declref_expr type='() -> ()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:1] decl=main.(file).f()@<stdin>:1:6 function_ref=single) (tuple_expr type='()' location=<stdin>:2:2 range=[<stdin>:2:2 - line:2:3]))
Avatar
omochimetaru 14-Mar-20 02:18 PM
@swift-nightly -frontend -typecheck
func f(aa: Int..., bb: Int, cc: Int) {} f(aa: 1, 2, 3, bbx: 4, cc: 5)
(edited)
Avatar
swiftNightly BOT 14-Mar-20 02:18 PM
exit status: 1 with stderr:
<stdin>:2:2: error: incorrect argument label in call (have 'aa:_:_:bbx:cc:', expected 'aa:_:_:bb:cc:') f(aa: 1, 2, 3, bbx: 4, cc: 5) ^ ~~~ bb
(edited)
Avatar
omochimetaru 14-Mar-20 02:23 PM
@swift-nightly -frontend -typecheck -debug-constraints
func f(aa: Int, bb: Int) {} f(aa: 1, aa: 2)
(edited)
Avatar
swiftNightly BOT 14-Mar-20 02:23 PM
exit status: 1 with stderr:
---Constraint solving at [<stdin>:2:1 - line:2:15]--- (overload set choice binding $T0 := (Int, Int) -> ()) (attempting fix [fix: re-label argument(s)] @ locator@0x95ce7c0 [Call@<stdin>:2:1 -> apply argument]) (increasing score due to attempting to fix the source) ---Initial constraints for the given expression--- (call_expr type='()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:15] arg_labels=aa:aa: (declref_expr type='(Int, Int) -> ()' location=<stdin>:2:1 range=[<stdin>:2:1 - line:2:1] decl=main.(file).f(aa:bb:)@<stdin>:1:6 function_ref=single) (tuple_expr type='(aa: $T1, aa: $T2)' location=<stdin>:2:2 range=[<stdin>:2:2 - line:2:15] names=aa,aa (integer_literal_expr type='$T1' location=<stdin>:2:7 range=[<stdin>:2:7 - line:2:7] value=1 builtin_initializer=**NULL** initializer=**NULL**) (integer_literal_expr type='$T2' location=<stdin>:2:14 range=[<stdin>:2:14 - line:2:14] value=2 builtin_initializer=**NULL** initializer=**NULL**))) Score: 2 0 0 0 0 0 0 0 0 0 0 0 Contextual Type: <null> Type Variables: $T0 [lvalue allowed] [noescape allowed] as (Int, Int) -> () @ locator@0x95ce4e0 [DeclRef@<stdin>:2:1] $T1 [noescape allowed] literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x95ce530 [IntegerLiteral@<stdin>:2:7] $T2 [noescape allowed] literal=3 bindings={(subtypes of) (default from ExpressibleByIntegerLiteral) Int} @ locator@0x95ce5e8 [IntegerLiteral@<stdin>:2:14] $T3 [noescape allowed] as () @ locator@0x95ce6f8 [Call@<stdin>:2:1 -> function result] Active Constraints: Inactive Constraints: $T1 literal conforms to ExpressibleByIntegerLiteral [[locator@0x95ce530 [IntegerLiteral@<stdin>:2:7]]]; $T2 literal conforms to ExpressibleByIntegerLiteral [[locator@0x95ce5e8 [IntegerLiteral@<stdin>:2:14]]]; $T1 arg conv Int [[locator@0x95ce818 [Call@<stdin>:2:1 -> apply argument -> comparing call argument #0 to parameter #0]]]; $T2 arg conv Int [[locator@0x95ce8a8
(edited)
Avatar
omochimetaru 15-Mar-20 11:03 AM
@swift-nightly -frontend -typecheck -enable-educational-notes -diagnostic-documentation-path /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/userdocs/diagnostics
protocol P { associatedtype T } func f(p: P) {}
Avatar
swiftNightly BOT 15-Mar-20 11:03 AM
exit status: 1 with stderr:
<stdin>:2:11: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements func f(p: P) {} ^
Avatar
omochimetaru 15-Mar-20 11:05 AM
@norio_nomura botってswiftのソースコード持ってますか?バイナリしか持ってない?
Avatar
norio_nomura 15-Mar-20 11:07 AM
ソースコードは持っていません。
https://hub.docker.com/r/norionomura/swift にボットと必要なライブラリを加えたDockerイメージで動いてます。
Avatar
omochimetaru 15-Mar-20 11:11 AM
なるほど。 ↑の-diagnostics-documentation-pathにswiftリポジトリの/userdocs/diagnostics を指定すると使える新機能があるので参照したかった。
Avatar
norio_nomura 15-Mar-20 11:13 AM
ふむ。ソースコード全体を持つのは容量的にちょっと厳しいかな。
Avatar
omochimetaru 15-Mar-20 11:14 AM
ああ、容量の負担があるのかあ。
そのうち /share とかにデプロイされるようになるといいな。
swift_install_in_component(DIRECTORY diagnostics DESTINATION "share/doc/swift" COMPONENT compiler)
いやなんかかいてあるな
@swift-nightly -frontend -typecheck -enable-educational-notes -diagnostic-documentation-path /usr/share/doc/swift/diagnostics
extension (Int, Int) {}
(edited)
Avatar
swiftNightly BOT 15-Mar-20 11:17 AM
exit status: 1 with stderr:
<stdin>:1:1: error: non-nominal type '(Int, Int)' cannot be extended extension (Int, Int) {} ^ ~~~~~~~~~~ Nominal types -------------- In Swift, a type is considered a nominal type if it is named. In other words, it has been defined by declaring the type somewhere in code. Examples of nominal types include classes, structs and enums, all of which must be declared before using them. Nominal types are an important concept in Swift because they can be extended, explicitly initialized using the 'MyType()' syntax, and may conform to protocols. In contrast, non-nominal types have none of these capabilities. A non-nominal type is any type which is not nominal. They are sometimes called “structural types” because they are usually obtained by composing other types. Examples include function types like '(Int) -> (String)', tuple types like '(Int, String)', metatypes like 'Int.Type', and special types like 'Any' and 'AnyObject'. Whether the name of a protocol refers to a nominal or non-nominal type depends on where it appears in code. When used in a declaration or extension like 'extension MyProtocol { … }', 'MyProtocol' refers to a protocol type, which is nominal. This means that it may be extended and conform to protocols. However, when written as the type of a constant or variable, 'MyProtocol' instead refers to a non-nominal, existential type. As a result, code like 'let value: MyProtocol = MyProtocol()' is not allowed because 'MyProtocol' refers to a non-nominal type in this context and cannot be explicitly initialized.
(edited)
Avatar
norio_nomura 15-Mar-20 11:17 AM
swift-5.2とswift-nightlyには /usr/share/doc/swift/diagnostics 入ってる。
🙏 1
Avatar
omochimetaru 15-Mar-20 11:18 AM
出た〜
Avatar
norio_nomura 15-Mar-20 11:19 AM
$ docker-swiftnightly-run ls -la /usr/share/doc/swift/diagnostics total 28 drwxr-xr-x 2 root root 4096 Mar 14 05:33 . drwxr-xr-x 3 root root 4096 Mar 14 05:33 .. -rw-r--r-- 1 root root 1898 Mar 14 04:05 associated-type-requirements.md -rw-r--r-- 1 root root 1162 Mar 14 04:05 complex-closure-inference.md -rw-r--r-- 1 root root 1501 Mar 14 04:05 dynamic-callable-requirements.md -rw-r--r-- 1 root root 1431 Mar 14 04:05 nominal-types.md -rw-r--r-- 1 root root 727 Mar 14 04:05 property-wrapper-requirements.md $ docker-swift52-run ls -la /usr/share/doc/swift/diagnostics total 16 drwxr-xr-x 2 root root 4096 Mar 15 09:30 . drwxr-xr-x 3 root root 4096 Mar 15 09:30 .. -rw-r--r-- 1 root root 1162 Mar 15 07:57 complex-closure-inference.md -rw-r--r-- 1 root root 1440 Mar 15 07:57 nominal-types.md
Avatar
omochimetaru 15-Mar-20 11:19 AM
@swift-nightly -frontend -typecheck -enable-experimental-diagnostic-formatting
extension (Int, Int) {}
Avatar
swiftNightly BOT 15-Mar-20 11:19 AM
exit status: 1 with stderr:
<stdin>:1:1 1 | extension (Int, Int) {} | ~~~~~~~~~~ | ^ error: non-nominal type '(Int, Int)' cannot be extended 2 |
Avatar
omochimetaru 15-Mar-20 11:20 AM
あとこれも。
Avatar
norio_nomura 15-Mar-20 11:20 AM
へー
Avatar
omochimetaru 15-Mar-20 11:21 AM
あと、GSoC2020で、エラーメッセージの国際化ってテーマも出てました。
エラーメッセージ系を強化したいっぽい。
Avatar
norio_nomura 15-Mar-20 11:21 AM
macOS版にも入ってるね。
Avatar
omochimetaru 15-Mar-20 11:22 AM
macOS版って?
Avatar
norio_nomura 15-Mar-20 11:22 AM
OSSツールチェイン
Avatar
omochimetaru 15-Mar-20 11:23 AM
あなるほど
Avatar
norio_nomura 15-Mar-20 11:25 AM
$ la (dirname (xcrun --toolchain org.swift.52202003141a -find swift))/../share/doc/swift/diagnostics total 16 drwxr-xr-x 4 norio staff 128B 3 15 11:16 ./ drwxr-xr-x 3 norio staff 96B 3 15 11:16 ../ -rw-r--r-- 1 norio staff 1.1K 3 15 07:56 complex-closure-inference.md -rw-r--r-- 1 norio staff 1.4K 3 15 07:56 nominal-types.md
Avatar
omochimetaru 15-Mar-20 11:26 AM
[omochi@omochi-iMacPro diagnostics]$ pwd /Applications/Xcode11.4.beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/doc/swift/diagnostics [omochi@omochi-iMacPro diagnostics]$ ls complex-closure-inference.md nominal-types.md
Xcode11.4 beta 3 にも同梱されてた。
Avatar
omochimetaru 15-Mar-20 11:36 AM
@swift-nightly -frontend -typecheck -enable-educational-notes -diagnostic-documentation-path /usr/share/doc/swift/diagnostics
protocol P { associatedtype T } func f(p: P) {}
Avatar
swiftNightly BOT 15-Mar-20 11:36 AM
exit status: 1 with stderr:
<stdin>:2:11: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements func f(p: P) {} ^ Using Protocols with 'Self' or Associated Type Requirements Protocols in Swift may be used as types, as part of a generic constraint, or as part of an opaque result type. // CustomStringConvertible can be used as a type. func foo(bar: CustomStringConvertible) { /* ... */ } // ...or as a generic constraint on 'T'. func bar<T: CustomStringConvertible>(baz: T) { /* ... */ } // ...or as part of an opaque result type. func baz() -> some CustomStringConvertible { /* ... */ } While all Swift protocols can be used as generic constraints and as part of opaque result types, not all protocols can be used as types in general. Specifically, if a protocol has a requirement which references 'Self' or an associated type, it cannot be used as a type. One such protocol is 'Identifiable', which has the requirement 'var id: ID { get }', where 'ID' is an associated type. As a result, the following code is not allowed: func foo(bar: Identifiable) { /* ... */ } // error: protocol 'Identifiable' can only be used as a generic constraint because it has Self or associated type requirements Protocols like 'Identifiable' which have 'Self' or associated type requirements cannot be used as types because such types would rarely be useful in practice. They would be unable to allow use of 'Self' or associated type requirements like 'var id: ID { get }' because the associated type is not specified. When working with protocols having 'Self' or associated type requirements constrained generics, opaque result types, or manual type erasure is sufficient to support most use cases. To learn more, see the [Protocols](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html), [Generics](https://docs.swift.org/swift-book/LanguageGuide/Generics.html), and [Opaque Types](https://docs.swif
Avatar
omochimetaru 15-Mar-20 11:37 AM
markdownのコードブロックを認識してインデントしてる。
リンク部分はそのままだ。まあリンク作れんしなあ。
Avatar
norio_nomura 15-Mar-20 12:47 PM
Xcode projectのOTHER_SWIFT_FLAGS-Xfrontend -enable-educational-notes -Xfrontend -diagnostic-documentation-path -Xfrontend $TOOLCHAIN_DIR/usr/share/doc/swift/diagnosticsって設定してエラーを出させてみたけど、Xcodeのエラーログではmarkdown syntax認識されなかった。
Avatar
omochimetaru 15-Mar-20 12:49 PM
IDE連携モードの時は生のマークダウンが渡ってて、将来的にはXcode側でレンダリングするのかな。 Xcodeからならリンク部分もクリックできるようになりそう。
結構良さそうな機能だな。PATとかみんなハマるし。
Avatar
norio_nomura 24-Mar-20 10:17 AM
全ボットダウン中…
Avatar
Kishikawa Katsumi 24-Mar-20 10:18 AM
あらら 🙏
Avatar
norio_nomura 24-Mar-20 11:59 AM
このDiscordサーバーが新しいFeatureをサポートするようになり、ボットで使ってるDiscordライブラリSwordがそのFeatureを認識出来なくてクラッシュしてた。
新しいFeatureはANIMATED_ICON guild has access to set an animated guild iconだったかな。
Avatar
omochimetaru 24-Mar-20 12:00 PM
もしかしてさっき @tarunon がboost課金したからか?
Avatar
tarunon 24-Mar-20 12:01 PM
お。。
それっぽいですね
AnimatedIconか。申し訳ない
Avatar
norio_nomura 24-Mar-20 12:01 PM
まあ、Swordが悪い。
Avatar
tarunon 24-Mar-20 12:02 PM
とりあえず1週間僕のboostきかなくなるんですが
対応まで外しておきます
Avatar
norio_nomura 24-Mar-20 12:02 PM
Swordが悪いと知ってて、それを古いままパッチ当てて使ってる僕が悪い。
5.0以降のボットは対応しました。 (edited)
Avatar
tarunon 24-Mar-20 12:02 PM
全完了したら戻すのでお知らせくださいまし (edited)
Avatar
norio_nomura 24-Mar-20 12:03 PM
古いボットもdeploy待ちなだけなので、戻していただいて構いません。
Avatar
tarunon 24-Mar-20 12:03 PM
ではそのままで。
🙂 1
Avatar
norio_nomura 24-Mar-20 01:21 PM
@swift-4.0.3 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-nightly -version
Avatar
swiftNightly BOT 24-Mar-20 01:21 PM
Swift version 5.3-dev (LLVM fa328efd5a, Swift 667bec0f21) Target: x86_64-unknown-linux-gnu
Avatar
swift50 BOT 24-Mar-20 01:21 PM
Swift version 5.0.3 (swift-5.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift42 BOT 24-Mar-20 01:21 PM
Swift version 4.2.4 (swift-4.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift51 BOT 24-Mar-20 01:21 PM
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift41 BOT 24-Mar-20 01:21 PM
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift40 BOT 24-Mar-20 01:21 PM
Swift version 4.0.3 (swift-4.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift52 BOT 24-Mar-20 01:21 PM
Swift version 5.2-dev (Swift 33150e32b4) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 24-Mar-20 01:22 PM
復帰した。
🙏 3
Avatar
nanasi 25-Mar-20 03:31 AM
@swift-5.2.5
class Foo: Foo.Base { class Base {} }
Avatar
swift52 BOT 25-Mar-20 03:31 AM
exit status: 1 with stderr:
<stdin>:1:7: error: circular reference class Foo: Foo.Base { ^ <stdin>:1:16: note: through reference here class Foo: Foo.Base { ^
Avatar
nanasi 25-Mar-20 03:31 AM
@swift-5.1.5
class Foo: Foo.Base { class Base {} }
Avatar
swift51 BOT 25-Mar-20 03:31 AM
no output
Avatar
omochimetaru 20-Apr-20 02:31 PM
@swift-5.2.5
struct S { let a: Int = 1 } S(a: 2)
Avatar
swift52 BOT 20-Apr-20 02:31 PM
exit status: 1 with stderr:
<stdin>:2:6: error: argument passed to call that takes no arguments S(a: 2) ^
Avatar
koher 22-Apr-20 04:05 AM
@swift-5.2.5 -O
class Foo { private let deinitBody: () -> Void init(_ deinitBody: @escaping () -> Void) { self.deinitBody = deinitBody } deinit { deinitBody() } } func main() { var a = 42 var foo = Foo {} foo = Foo { a = -1 } let _ = foo // to ignore warnings print(a) } main()
(edited)
Avatar
swift52 BOT 22-Apr-20 04:05 AM
-1
(edited)
Avatar
norio_nomura 22-Apr-20 10:39 PM
@swift-5.3.3 -version
Avatar
swift53 BOT 22-Apr-20 10:39 PM
Swift version 5.3-dev (LLVM 38f04f051e, Swift 587da7ce60) Target: x86_64-unknown-linux-gnu
Avatar
nanasi 30-Apr-20 08:09 AM
@swift-5.2.5 @swift-5.3.3
class Record { var storage: [String: Any] init(_ storage: [String: Any]) { self.storage = storage } } extension Record { @propertyWrapper public struct Field<Value> { @available(*, unavailable) public var wrappedValue: Value { fatalError("only works on instance properties of classes") } private let key: String public init(key: String) { self.key = key } public static subscript<Instance: Record>( _enclosingInstance instance: Instance, wrapped wrappedKeyPath: KeyPath<Instance, Value>, storage storageKeyPath: ReferenceWritableKeyPath<Instance, Self> ) -> Value { let field = instance[keyPath: storageKeyPath] return instance.storage[field.key] as! Value } } } class User: Record { @Field(key: "id") var id: Int } let user = User(["id": 100]) print(user.id)
(edited)
Avatar
swift52 BOT 30-Apr-20 08:09 AM
100
(edited)
Avatar
swift53 BOT 30-Apr-20 08:09 AM
100
(edited)
Avatar
nanasi 30-Apr-20 08:40 AM
@swift-5.3.3
class Record { var storage: [String: Any] init(_ storage: [String: Any]) { self.storage = storage } } extension Record { @propertyWrapper public struct Field<Value> { @available(*, unavailable) public var wrappedValue: Value { get { fatalError("only works on instance properties of classes") } set { fatalError("only works on instance properties of classes") } } private let key: String public init(key: String) { self.key = key } public static subscript<Instance: Record>( _enclosingInstance instance: Instance, wrapped wrappedKeyPath: ReferenceWritableKeyPath<Instance, Value>, storage storageKeyPath: ReferenceWritableKeyPath<Instance, Self> ) -> Value { get { let field = instance[keyPath: storageKeyPath] return instance.storage[field.key] as! Value } set {} } } } class User: Record { @Field(key: "id") var id: Int } let user = User(["id": 100]) print(user.id)
(edited)
Avatar
swift53 BOT 30-Apr-20 08:40 AM
100
(edited)
Avatar
nanasi 01-May-20 02:44 AM
@swift-5.3.3
class Base { class var keyPath: AnyKeyPath { fatalError() } } final class Derived: Base { override class var keyPath: AnyKeyPath { \Self.value } var value: Int = 0 } print(Derived.keyPath)
Avatar
swift53 BOT 01-May-20 02:44 AM
exit status: 4 with stderr:
Fatal error: could not demangle keypath type from '�: file /home/buildnode/jenkins/workspace/oss-swift-5.3-package-linux-ubuntu-16_04/swift/stdlib/public/core/KeyPath.swift, line 2623 Current stack trace: 0 libswiftCore.so 0x00007fa81bf3dc30 swift_reportError + 50 1 libswiftCore.so 0x00007fa81bfb01a0 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fa81bc7b465 <unavailable> + 1410149 3 libswiftCore.so 0x00007fa81bc7b0a7 <unavailable> + 1409191 4 libswiftCore.so 0x00007fa81bc7b642 <unavailable> + 1410626 5 libswiftCore.so 0x00007fa81bc79a70 _assertionFailure(_:_:file:line:flags:) + 523 6 libswiftCore.so 0x00007fa81bd55451 <unavailable> + 2303057 7 libswiftCore.so 0x00007fa81bd556ae <unavailable> + 2303662 8 libswiftCore.so 0x00007fa81bd54c97 <unavailable> + 2301079 9 libswiftCore.so 0x00007fa81bd54990 _swift_getKeyPath(pattern:arguments:) + 120 12 swift 0x0000000000599cdc <unavailable> + 1678556 13 swift 0x000000000058723f <unavailable> + 1602111 14 swift 0x000000000056c471 <unavailable> + 1492081 15 swift 0x000000000055fa38 <unavailable> + 1440312 16 swift 0x000000000055c87e <unavailable> + 1427582 17 swift 0x00000000004d653b <unavailable> + 877883 18 libc.so.6 0x00007fa81e044740 __libc_start_main + 240 19 swift 0x00000000004d5fe9 <unavailable> + 876521 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftB
Avatar
ikesyo 13-May-20 12:41 PM
@swift-5.1.5 @swift-5.2.5
func foo(_ closure: () -> Void, defaultArg: Int = 0) { closure() } foo { print("foo") }
Avatar
swift51 BOT 13-May-20 12:41 PM
exit status: 1 with stderr:
<stdin>:5:4: error: missing argument for parameter #1 in call foo { print("foo") } ^ (<#() -> Void#>) <stdin>:1:6: note: 'foo(_:defaultArg:)' declared here func foo(_ closure: () -> Void, defaultArg: Int = 0) { ^
Avatar
swift52 BOT 13-May-20 12:41 PM
foo
Avatar
ikesyo 13-May-20 12:42 PM
やはりSwift 5.2から最後の引数がデフォルト引数の時に、その1つ前のクロージャがtrailing closureとして呼べるようになっている
Avatar
yutailang0119 13-May-20 12:56 PM
SE-0279の下準備がされていた?
Avatar
omochimetaru 13-May-20 03:45 PM
0279の前からmasterでは入ってたよ (edited)
Avatar
ikesyo 13-May-20 11:43 PM
なるほどー。いつくらいの変更なんだろう。
https://github.com/Quick/Nimble/issues/755 これで動き見てて気付きました
I have read CONTRIBUTING and have done my best to follow them. What did you do? Using containElementSatisfying in swift test using XCTest (not QuickSpec). Tests compile and run in Xcode 11.4 on my ...
Avatar
omochimetaru 14-May-20 02:01 AM
クロージャの部分がautoclosureなケースであてはまったのか
…efaulted If the last parameter is defaulted, there might be an attempt to use a trailing closure with previous parameter that accepts a function type e.g. ```swift func foo(_: () -&gt; Int, ...
いつくらいの変更なんだろう。
2019/11/2のコミット。半年前ですね。
Avatar
yutailang0119 14-May-20 02:06 AM
結構前だった
Avatar
omochimetaru 14-May-20 02:07 AM
これデフォルト引数が一個の場合だけしかできなくて
Avatar
ikesyo 14-May-20 02:07 AM
おー、ありがとうございます!
Avatar
omochimetaru 14-May-20 02:08 AM
2個や3個でも同じ挙動になるべきだろうと思って
This patch improve trailing closure matching with parameters. Currently, trailing closure can match with function parameter followed by one defaulted parameter. But it can not do if: function type...
PRを出したらマージされたんだけど、そのあといろいろあってrevertされた。
Avatar
ikesyo 14-May-20 02:10 AM
なるほど https://bugs.swift.org/browse/SR-12291 これ、Nimbleのビルドがエラーになったやつだ。 https://github.com/Quick/Nimble/issues/733
https://travis-ci.org/github/Quick/Nimble/jobs/669964944 /home/travis/build/Quick/Nimble/Tests/NimbleTests/Matchers/PostNotificationTest.swift:17:9: error: ambiguous use of &#39;expect&#39;...
Avatar
omochimetaru 14-May-20 02:11 AM
これさ〜
2このケースでリグレッションになるなら
同じ理屈で1このケースでもリグレッションがあったはずだと思うんだけど😠
Avatar
ikesyo 14-May-20 02:13 AM
この件があったからsource-compat-suiteにNimble追加してくれたのか https://github.com/apple/swift-source-compat-suite/pull/418
The overload resolution broke recently on master (SR-12291). Add this to the test suite for future testing. Pull Request Description Replace with a description of this pull request. Instructions f...
Avatar
omochimetaru 14-May-20 02:14 AM
そんな因果がw
じゃあ俺がPR29845をやったことでNimbleがそこに入ったって事だw
😆 1
Avatar
ikesyo 14-May-20 02:17 AM
色々話が繋がって面白い、助かりました 🙌
😀 1
Avatar
Iceman 02-Jun-20 04:49 PM
@swift-5.3.3
protocol Dekiru { static var hoge: Dekiruzo { get } } enum Dekiruzo: Dekiru { case hoge }
(edited)
Avatar
swift53 BOT 02-Jun-20 04:49 PM
no output (edited)
Avatar
Iceman 02-Jun-20 04:51 PM
@swift-5.3.3
protocol P { associatedtype T static var hoge: Types<T> { get } } enum Types<T>: P { case hoge }
Avatar
swift53 BOT 02-Jun-20 04:51 PM
no output
Avatar
Iceman 02-Jun-20 04:51 PM
@swift-5.3.3
protocol P { static var hoge: Types<Int> { get } } enum Types<T>: P { case hoge }
Avatar
swift53 BOT 02-Jun-20 04:51 PM
exit status: 1 with stderr:
<stdin>:5:6: error: type 'Types<T>' does not conform to protocol 'P' enum Types<T>: P { ^ <stdin>:6:10: note: candidate has non-matching type '<T> (Types<T>.Type) -> Types<T>' case hoge ^ <stdin>:2:16: note: protocol requires property 'hoge' with type 'Types<Int>'; do you want to add a stub? static var hoge: Types<Int> { get } ^
Avatar
Iceman 02-Jun-20 04:57 PM
@swift-5.3.3
protocol P { static var hoge: Types<Int> { get } } enum Types<T> { case hoge } extension Types: P where T == Int {} func use<T>(_ type: Types<T>) { print("1", type) } use(.hoge)
(edited)
Avatar
swift53 BOT 02-Jun-20 04:57 PM
exit status: 1 with stderr:
<stdin>:15:1: error: generic parameter 'T' could not be inferred use(.hoge) ^ <stdin>:11:6: note: in call to function 'use' func use<T>(_ type: Types<T>) { ^
(edited)
Avatar
nanasi 16-Jun-20 07:14 AM
@swift-5.3.3
protocol EntityProtocol { associatedtype ID init(id: ID) } class Entity<ID>: EntityProtocol { let id: ID required init(id: ID) { self.id = id } enum CodingKeys: CodingKey { case id(String) var stringValue: String { switch self { case .id(let id): return id } } var intValue: Int? { nil } init?(stringValue: String) { self = .id(stringValue) } init?(intValue: Int) { return nil } } class func codingKeysForID() -> CodingKeys { .id("id") } } extension EntityProtocol where Self: Decodable, ID: Decodable { init(from decoder: Decoder) throws { let type = Self.self as! Entity<ID>.Type let c = try decoder.container(keyedBy: type.CodingKeys.self) self.init(id: try c.decode(ID.self, forKey: type.codingKeysForID())) } }
(edited)
Avatar
swift53 BOT 16-Jun-20 07:16 AM
no output
Avatar
nanasi 18-Jun-20 02:23 AM
@swift-5.3.3
struct MySet<Element: Hashable> { private var set: Set<Element> } extension MySet: Collection { subscript(idx: Set<Element>.Index) -> Element { set[idx] } var startIndex: Set<Element>.Index { set.startIndex } var endIndex: Set<Element>.Index { set.endIndex } func index(after i: Set<Element>.Index) -> Set<Element>.Index { set.index(after: i) } }
(edited)
Avatar
swift53 BOT 18-Jun-20 02:23 AM
exit status: 1 with stderr:
<stdin>:6:56: error: expected '{' to start setter definition subscript(idx: Set<Element>.Index) -> Element { set[idx] } ^ <stdin>:7:45: error: expected '{' to start setter definition var startIndex: Set<Element>.Index { set.startIndex } ^ <stdin>:8:43: error: expected '{' to start setter definition var endIndex: Set<Element>.Index { set.endIndex } ^
(edited)
Avatar
nanasi 18-Jun-20 02:30 AM
@swift-5.3.3
struct MySet<Element: Hashable> { private var _set: Set<Element> } extension MySet: Collection { subscript(idx: Set<Element>.Index) -> Element { _set[idx] } var startIndex: Set<Element>.Index { _set.startIndex } var endIndex: Set<Element>.Index { _set.endIndex } func index(after i: Set<Element>.Index) -> Set<Element>.Index { _set.index(after: i) } }
Avatar
swift53 BOT 18-Jun-20 02:30 AM
no output
Avatar
tarunon 03-Jul-20 01:54 AM
@swift-5.2.5
import Foundation protocol Foo: NSObjectProtocol { func a() } class Bar: NSObject, Foo { func a() { } } print(class_getInstanceMethod(Bar.self, Selector("a")))
Avatar
swift52 BOT 03-Jul-20 01:54 AM
exit status: 1 with stderr:
<stdin>:13:7: error: use of unresolved identifier 'class_getInstanceMethod' print(class_getInstanceMethod(Bar.self, Selector("a"))) ^~~~~~~~~~~~~~~~~~~~~~~ <stdin>:13:41: error: use of unresolved identifier 'Selector' print(class_getInstanceMethod(Bar.self, Selector("a"))) ^~~~~~~~
Avatar
tarunon 03-Jul-20 01:54 AM
無いか…
Avatar
Iceman 14-Jul-20 06:56 AM
@swift-5.2.5
class A { class var i: String { "i" } init() {} func setup() { a = { if let a = self.a { return a() } return Self.i } } var a: (() -> String)? } class Test { weak var a: A? init(a: A) { self.a = a a.setup() } func main() { print(a?.a?()) } } Test(a: A()).main()
Avatar
swift52 BOT 14-Jul-20 06:56 AM
exit status: 11 with stderr:
<stdin>:21:15: warning: expression implicitly coerced from 'String?' to 'Any' print(a?.a?()) ^~~~~~~ <stdin>:21:19: note: provide a default value to avoid this warning print(a?.a?()) ~~~~^~~ ?? <#default value#> <stdin>:21:19: note: force-unwrap the value to avoid this warning print(a?.a?()) ~~~~^~~ ! <stdin>:21:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a?.a?()) ~~~~^~~ as Any Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-m
Avatar
Iceman 14-Jul-20 06:57 AM
@swift-5.3.3
class A { class var i: String { "i" } init() {} func setup() { a = { if let a = self.a { return a() } return Self.i } } var a: (() -> String)? } class Test { weak var a: A? init(a: A) { self.a = a a.setup() } func main() { print(a?.a?()) } } Test(a: A()).main()
Avatar
swift53 BOT 14-Jul-20 06:57 AM
exit status: 11 with stderr:
<stdin>:21:15: warning: expression implicitly coerced from 'String?' to 'Any' print(a?.a?()) ^~~~~~~ <stdin>:21:19: note: provide a default value to avoid this warning print(a?.a?()) ~~~~^~~ ?? <#default value#> <stdin>:21:19: note: force-unwrap the value to avoid this warning print(a?.a?()) ~~~~^~~ ! <stdin>:21:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a?.a?()) ~~~~^~~ as Any Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-m
Avatar
Iceman 18-Jul-20 04:49 PM
@swift-nightly
struct NotEquatable {} func test() { struct A: Equatable { var value: NotEquatable static func == (lhs: A, rhs: A) -> Bool { true } } }
Avatar
swiftNightly BOT 18-Jul-20 04:49 PM
exit status: 1 with stderr:
<stdin>:4:12: error: type 'A' does not conform to protocol 'Equatable' struct A: Equatable { ^ <stdin>:5:13: note: stored property type 'NotEquatable' does not conform to protocol 'Equatable', preventing synthesized conformance of 'A' to 'Equatable' var value: NotEquatable ^ Swift.==:1:24: note: candidate would match if 'A' conformed to 'RawRepresentable' @inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.FloatingPoint:2:24: note: candidate would match if 'A' conformed to 'FloatingPoint' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.BinaryInteger:2:24: note: candidate would match if 'A' conformed to 'BinaryInteger' public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger ^ Swift._Pointer:2:24: note: candidate would match if 'A' conformed to '_Pointer' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Strideable:3:35: note: candidate would match if 'A' conformed to 'Strideable' @inlinable public static func == (x: Self, y: Self) -> Bool ^ Swift.StringProtocol:2:35: note: candidate would match if 'A' conformed to 'StringProtocol' @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol ^ Swift.SIMD:4:24: note: candidate would match if 'A' conformed to 'SIMD' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Equatable:2:17: note: protocol requires function '==' with type '(A, A) -> Bool' static func == (lhs: Self, rhs: Self) -> Bool ^
Avatar
tarunon 31-Jul-20 11:08 AM
@swift-5.2.5 -emit-ir
func contains(i: Int, lim: Int) -> Bool { (0..<lim).contains(i) } contains(1, 100)
Avatar
swift52 BOT 31-Jul-20 11:08 AM
exit status: 1 with stderr:
<unknown>:0: error: option '-emit-ir' is not supported by 'swift'; did you mean to use 'swiftc'?
Avatar
norio_nomura 01-Aug-20 12:42 AM
-frontendの後に付けると動きます。 @swift-5.2.5 -frontend -emit-ir
func contains(_ i: Int, _ lim: Int) -> Bool { (0..<lim).contains(i) } contains(1, 100)
Avatar
swift52 BOT 01-Aug-20 12:42 AM
; ModuleID = '-' source_filename = "-" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" module asm ".section .swift1_autolink_entries,\220x80000000\22" %TSnySiG = type <{ %TSi, %TSi }> %TSi = type <{ i64 }> @0 = private unnamed_addr constant [46 x i8] c"Can't form Range with upperBound < lowerBound\00" @1 = private unnamed_addr constant [112 x i8] c"/home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-16_04/swift/stdlib/public/core/Range.swift\00" @2 = private unnamed_addr constant [12 x i8] c"Fatal error\00" @__swift_reflection_version = linkonce_odr hidden constant i16 3 @_swift1_autolink_entries = private constant [49 x i8] c"-lswiftSwiftOnoneSupport\00-lswiftCore\00-lLibraries\00", section ".swift1_autolink_entries", align 8 @llvm.used = appending global [2 x i8*] [i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata", align 8 define protected i32 @main(i32, i8**) #0 { entry: %2 = bitcast i8** %1 to i8* %3 = call swiftcc i1 @"$s4main8containsySbSi_SitF"(i64 1, i64 100) ret i32 0 } define hidden swiftcc i1 @"$s4main8containsySbSi_SitF"(i64, i64) #0 { entry: %i.debug = alloca i64, align 8 %2 = bitcast i64* %i.debug to i8* call void @llvm.memset.p0i8.i64(i8* align 8 %2, i8 0, i64 8, i1 false) %lim.debug = alloca i64, align 8 %3 = bitcast i64* %lim.debug to i8* call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 8, i1 false) %4 = alloca %TSnySiG, align 8 %5 = alloca %TSi, align 8 %6 = alloca %TSi, align 8 %7 = alloca %TSnySiG, align 8 %8 = alloca %TSi, align 8 store i64 %0, i64* %i.debug, align 8 store i64 %1, i64* %lim.debug, align 8 %9 = bitcast %TSnySiG* %4 to i8* call void @llvm.lifetime.start.p0i8(i64 16, i8* %9) br label %10 10: ; preds = %entry %11 = icmp slt i64 %1, 0
🙏 1
Avatar
norio_nomura 05-Aug-20 06:30 AM
@swift-5.2.5 -version
Avatar
swift52 BOT 05-Aug-20 06:30 AM
Swift version 5.2.4-dev (Swift b623e823d4) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 05-Aug-20 06:38 AM
あーこれswift-5.2.5-RELEASEタグが付いたけど、やり直しになるパターンだ…
Avatar
omochimetaru 05-Aug-20 06:39 AM
どういうことです?
Avatar
norio_nomura 05-Aug-20 06:39 AM
swift -versionが5.2.4-devを返して来る。
Avatar
omochimetaru 05-Aug-20 06:40 AM
swift-5.2.5-RELEASEタグを付ける時にバージョン定義を5.2.5に変更するのを忘れてたのか。
Avatar
norio_nomura 05-Aug-20 06:44 AM
バージョンの横に表示されてるb623e823d4ってコミットのハッシュではないのかな?
Avatar
omochimetaru 05-Aug-20 06:44 AM
え、そうだと思ってた
Version.cpp のコミットハッシュとか。
Avatar
Avatar
omochimetaru 05-Aug-20 06:48 AM
あ、ほんとだ、これがそのハッシュですね
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
↑こっちかと思ってたけど、こっちは #define を参照してるだけだから、
Version.cpp自体は変化しなかったか。
#define の値をセットしてるのはそのCMakeList.txtですね。
Avatar
norio_nomura 05-Aug-20 06:51 AM
ci.swift.orgのログを見ると、直前までそのハッシュでテストビルドしてたみたいだから、正式リリースバイナリとは違いそう。 https://ci.swift.org/view/Packages/job/oss-swift-5.2-package-linux-ubuntu-16_04/
Avatar
omochimetaru 05-Aug-20 06:51 AM
なんども付け替えてるんですかね?
Avatar
norio_nomura 05-Aug-20 06:52 AM
ボットの更新はgithubにタグがついて、タグから予想される予定地にファイルが現れたらリリースとみなしてる。
forums.swift.orgでアナウンスされない限り、正式リリースでは無いと考えておくべきかな。
Avatar
omochimetaru 05-Aug-20 06:53 AM
なるほど。
Avatar
norio_nomura 05-Aug-20 06:54 AM
swift-5.2.5-RELEASEをプレイしているつもり。
Avatar
omochimetaru 05-Aug-20 06:55 AM
なるほどw
Avatar
norio_nomura 06-Aug-20 12:26 AM
@swift-5.2.5 -version
Avatar
swift52 BOT 06-Aug-20 12:26 AM
Swift version 5.2.5 (swift-5.2.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 21-Aug-20 06:08 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
func asyncFunc() async { print(#function) } await asyncFunc()
fastparrot 1
Avatar
swiftNightly BOT 21-Aug-20 06:08 AM
asyncFunc()
Avatar
rintaro 28-Aug-20 05:02 PM
@swift-4.0.3
protocol P {} struct S<T: P> {} func fun<T>(arg: S<T>) {}
Avatar
swift40 BOT 28-Aug-20 05:02 PM
no output
Avatar
nanasi 02-Sep-20 07:02 AM
@swift-5.2.5 -O
import Foundation protocol P { var prev: P? { get set } } struct Foo: P, CustomStringConvertible { var prev: P? let uuid = UUID() var description: String { "Foo(prev: \(prev.map { String(describing: $0) } ?? "nil"), uuid: \(uuid.uuidString.prefix(4)))" } } func insert(_ p: P, into array: inout [P], _ prev: inout P?) { var p = p p.prev = prev prev = p print("new p =", p) array.append(p) } var p: P? var result: [P] = [] insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) for r in result { print("inserted =", r) } print("last 'p' =", p!)
(edited)
Avatar
swift52 BOT 02-Sep-20 07:02 AM
new p = Foo(prev: nil, uuid: 5D6E) new p = Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264) new p = Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51), uuid: 0A52) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51), uuid: 0A52), uuid: 381A) inserted = Foo(prev: nil, uuid: 5D6E) inserted = Foo(prev: nil, uuid: 0264) inserted = Foo(prev: nil, uuid: B254) inserted = Foo(prev: nil, uuid: 5D51) inserted = Foo(prev: nil, uuid: 0A52) inserted = Foo(prev: nil, uuid: 381A) last 'p' = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 5D6E), uuid: 0264), uuid: B254), uuid: 5D51), uuid: 0A52), uuid: 381A)
(edited)
Avatar
nanasi 02-Sep-20 07:03 AM
@swift-5.2.5
import Foundation protocol P { var prev: P? { get set } } struct Foo: P, CustomStringConvertible { var prev: P? let uuid = UUID() var description: String { "Foo(prev: \(prev.map { String(describing: $0) } ?? "nil"), uuid: \(uuid.uuidString.prefix(4)))" } } func insert(_ p: P, into array: inout [P], _ prev: inout P?) { var p = p p.prev = prev prev = p print("new p =", p) array.append(p) } var p: P? var result: [P] = [] insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) insert(Foo(), into: &result, &p) for r in result { print("inserted =", r) } print("last 'p' =", p!)
Avatar
swift52 BOT 02-Sep-20 07:03 AM
new p = Foo(prev: nil, uuid: 0628) new p = Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A) new p = Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27) new p = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27), uuid: 6E9E) inserted = Foo(prev: nil, uuid: 0628) inserted = Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A) inserted = Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7) inserted = Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7) inserted = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27) inserted = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27), uuid: 6E9E) last 'p' = Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: Foo(prev: nil, uuid: 0628), uuid: A27A), uuid: 85E7), uuid: 12A7), uuid: 7C27), uuid: 6E9E)
Avatar
nanasi 02-Sep-20 07:05 AM
最適化で結果が変わる🤔
Avatar
takka 14-Sep-20 04:39 AM
@swift-5.2.5
import Foundation @propertyWrapper struct DefaultValue<Storage: DefaultValueStorage>: Decodable { var wrappedValue: Storage.Value = Storage.value } extension DefaultValue { init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() self.wrappedValue = try container.decode(Storage.Value.self) } } protocol DefaultValueStorage { associatedtype Value: Decodable static var value: Value { get } } enum DefaultValueStorages { enum Nil<T: Decodable>: DefaultValueStorage { static var value: T? { nil } } } // MARK: - 1. 直接書く struct S1 { @DefaultValue<DefaultValueStorages.Nil<String>> var string } // MARK: - 2. 別enumでtypealiasする enum Default { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S2 { @Default.Nil<String> var string } // MARK: - 3. extension DefaultValueでtypealiasする extension DefaultValue { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S3 { @DefaultValue.Nil<String> var string }
Avatar
swift52 BOT 14-Sep-20 04:39 AM
exit status: 134 with stderr:
<stdin>:27:57: error: type annotation missing in pattern @DefaultValue<DefaultValueStorages.Nil<String>> var string ^ <stdin>:35:30: error: type annotation missing in pattern @Default.Nil<String> var string ^ swift: /home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-16_04/swift/lib/Sema/TypeCheckType.cpp:865: static swift::Type swift::TypeChecker::applyUnboundGenericArguments(swift::UnboundGenericType *, swift::GenericTypeDecl *, swift::SourceLoc, swift::TypeResolution, ArrayRef<swift::Type>): Assertion `!resultType->hasTypeParameter()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libr
Avatar
takka 14-Sep-20 04:41 AM
@swift-5.3.3
import Foundation @propertyWrapper struct DefaultValue<Storage: DefaultValueStorage>: Decodable { var wrappedValue: Storage.Value = Storage.value } extension DefaultValue { init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() self.wrappedValue = try container.decode(Storage.Value.self) } } protocol DefaultValueStorage { associatedtype Value: Decodable static var value: Value { get } } enum DefaultValueStorages { enum Nil<T: Decodable>: DefaultValueStorage { static var value: T? { nil } } } // MARK: - 1. 直接書く struct S1 { @DefaultValue<DefaultValueStorages.Nil<String>> var string } // MARK: - 2. 別enumでtypealiasする enum Default { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S2 { @Default.Nil<String> var string } // MARK: - 3. extension DefaultValueでtypealiasする extension DefaultValue { typealias Nil<T: Decodable> = DefaultValue<DefaultValueStorages.Nil<T>> } struct S3 { @DefaultValue.Nil<String> var string }
(edited)
Avatar
swift53 BOT 14-Sep-20 04:41 AM
exit status: 134 with stderr:
swift: /home/buildnode/jenkins/workspace/oss-swift-5.3-package-linux-ubuntu-16_04/swift/lib/Sema/TypeCheckType.cpp:881: swift::Type swift::TypeChecker::applyUnboundGenericArguments(swift::UnboundGenericType *, swift::GenericTypeDecl *, swift::SourceLoc, swift::TypeResolution, ArrayRef<swift::Type>): Assertion `!resultType->hasTypeParameter()' failed. Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -module-name main -lLibraries 1. Swift version 5.3-dev (LLVM b87e6c6a2b, Swift 6446e640ec) 2. While evaluating request TypeCh
(edited)
Avatar
norio_nomura 16-Sep-20 09:39 PM
@swift-5.3.3 -version
Avatar
swift53 BOT 16-Sep-20 09:39 PM
Swift version 5.3 (swift-5.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
niw 24-Sep-20 10:01 PM
@swift-5.3.3
struct Container<Value> { var value: Value init(value: Value) { self.value = value } func withValue(action: (Value) -> ()) { action(value) } } var container = Container<Any>(value: "foo") container.withValue { value in print(value) container.value = "bar" print(value) }
Avatar
swift53 BOT 24-Sep-20 10:01 PM
exit status: 1 with stderr:
<stdin>:2:9: error: initializers may only be declared within a type init(value: Value) { ^ <stdin>:8:1: error: extraneous '}' at top level } ^ <stdin>:1:16: error: cannot find type 'Value' in scope var value: Value ^~~~~ <stdin>:5:29: error: cannot find type 'Value' in scope func withValue(action: (Value) -> ()) { ^~~~~ <stdin>:10:17: error: cannot find 'Container' in scope var container = Container<Any>(value: "foo") ^~~~~~~~~
Avatar
niw 24-Sep-20 10:03 PM
@swift-5.3.3
class Container<Value> { var value: Value init(value: Value) { self.value = value } func withValue(action: (Value) -> ()) { action(value) } } let container = Container<Any>(value: "foo") container.withValue { value in print(value) container.value = "bar" print(value) }
(edited)
Avatar
swift53 BOT 24-Sep-20 10:03 PM
exit status: 1 with stderr:
<stdin>:2:9: error: initializers may only be declared within a type init(value: Value) { ^ <stdin>:8:1: error: extraneous '}' at top level } ^ <stdin>:1:16: error: cannot find type 'Value' in scope var value: Value ^~~~~ <stdin>:5:29: error: cannot find type 'Value' in scope func withValue(action: (Value) -> ()) { ^~~~~ <stdin>:10:17: error: cannot find 'Container' in scope let container = Container<Any>(value: "foo") ^~~~~~~~~
Avatar
rintaro 24-Sep-20 11:05 PM
@swift-5.3.3
struct Container { var value: Any = "foo" func withValue(action: (Any) -> Void) { action(value) } } var container = Container() container.withValue { value in print(value) container.value = "bar" print(value) }
Avatar
swift53 BOT 24-Sep-20 11:05 PM
foo foo
Avatar
rintaro 24-Sep-20 11:06 PM
@swift-5.3.3 -O
struct Container { var value: Any = "foo" func withValue(action: (Any) -> Void) { action(value) } } var container = Container() container.withValue { value in print(value) container.value = "bar" print(value) }
Avatar
swift53 BOT 24-Sep-20 11:06 PM
foo bar
Avatar
rintaro 24-Sep-20 11:06 PM
@swift-5.2.5 -O
struct Container { var value: Any = "foo" func withValue(action: (Any) -> Void) { action(value) } } var container = Container() container.withValue { value in print(value) container.value = "bar" print(value) }
(edited)
Avatar
swift52 BOT 24-Sep-20 11:06 PM
foo foo
(edited)
Avatar
rintaro 24-Sep-20 11:27 PM
@swift-5.2.5 -O @swift-5.3.3 -O
var global: Any = 1 func withValue(action: (Any) -> Void) { action(global) } withValue { value in print(value) global = 24 print(value) }
(edited)
Avatar
swift53 BOT 24-Sep-20 11:27 PM
1 24
(edited)
Avatar
swift52 BOT 24-Sep-20 11:27 PM
1 1
(edited)
Avatar
koher 26-Sep-20 08:47 AM
@swift-nightly
import Foundation func download(from url: URL) async throws -> Data { fatalError("Unimplemented yet.") } let url: URL! = nil @asyncHandler func onButtonPressed(_ sender: Any) { do { let data = try await download(from: url) print(data.count) } catch { print("\(error)") } }
Avatar
swiftNightly BOT 26-Sep-20 08:47 AM
exit status: 1 with stderr:
<stdin>:3:29: error: consecutive statements on a line must be separated by ';' func download(from url: URL) async throws -> Data { ^ ; <stdin>:9:2: error: 'asyncHandler' attribute is only valid when experimental concurrency is enabled @asyncHandler ^ <stdin>:12:29: error: consecutive statements on a line must be separated by ';' let data = try await download(from: url) ^ ; <stdin>:3:6: error: expected '{' in body of function declaration func download(from url: URL) async throws -> Data { ^ <stdin>:3:30: error: cannot find 'async' in scope func download(from url: URL) async throws -> Data { ^~~~~ <stdin>:3:30: error: expected type before '->' func download(from url: URL) async throws -> Data { ^ <stdin>:3:46: error: expected type after '->' func download(from url: URL) async throws -> Data { ^ <stdin>:12:24: error: cannot find 'await' in scope let data = try await download(from: url) ^~~~~
Avatar
koher 26-Sep-20 08:47 AM
async/await なんかフラグがいるんだっけ (edited)
Avatar
kateinoigakukun 26-Sep-20 08:49 AM
-enable-experimental-concurrency
@swift-nightly -Xfrontend -enable-experimental-concurrency
import Foundation func download(from url: URL) async throws -> Data { fatalError("Unimplemented yet.") } let url: URL! = nil @asyncHandler func onButtonPressed(_ sender: Any) { do { let data = try await download(from: url) print(data.count) } catch { print("\(error)") } }
Avatar
swiftNightly BOT 26-Sep-20 08:49 AM
no output
Avatar
koher 26-Sep-20 08:57 AM
おお、すごい!もうコンパイルできてる。
Avatar
kateinoigakukun 26-Sep-20 08:58 AM
型チェックだけじゃなくて、ちゃんと実行可能形式として動くんですね
Avatar
koher 26-Sep-20 08:58 AM
今調べてたら昨日話してた以外にも大量の PR が見つかって、動きそうな感じがしました。
Avatar
kateinoigakukun 26-Sep-20 08:58 AM
@swift-nightly -Xfrontend -emit-sil -Xfrontend -enable-experimental-concurrency
import Foundation func download(from url: URL) async throws -> Data { fatalError("Unimplemented yet.") } let url: URL! = nil @asyncHandler func onButtonPressed(_ sender: Any) { do { let data = try await download(from: url) print(data.count) } catch { print("\(error)") } }
Avatar
swiftNightly BOT 26-Sep-20 08:58 AM
sil_stage canonical import Builtin import Swift import SwiftShims import Foundation func download(from url: URL) async throws -> Data @_hasStorage @_hasInitialValue let url: URL! { get } @asyncHandler func onButtonPressed(_ sender: Any) // url sil_global hidden [let] @$s4main3url10Foundation3URLVSgvp : $Optional<URL> // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): alloc_global @$s4main3url10Foundation3URLVSgvp // id: %2 %3 = global_addr @$s4main3url10Foundation3URLVSgvp : $*Optional<URL> // user: %5 %4 = enum $Optional<URL>, #Optional.none!enumelt // user: %5 store %4 to %3 : $*Optional<URL> // id: %5 %6 = integer_literal $Builtin.Int32, 0 // user: %7 %7 = struct $Int32 (%6 : $Builtin.Int32) // user: %8 return %7 : $Int32 // id: %8 } // end sil function 'main' // download(from:) sil hidden @$s4main8download4from10Foundation4DataVAD3URLV_tYKF : $@convention(thin) (@guaranteed URL) -> (@owned Data, @error Error) { // %0 "url" // user: %1 bb0(%0 : $URL): debug_value %0 : $URL, let, name "url", argno 1 // id: %1 debug_value undef : $Error, var, name "$error", argno 2 // id: %2 %3 = string_literal utf8 "main/<stdin>" // user: %5 %4 = integer_literal $Builtin.Word, 12 // user: %9 %5 = builtin "ptrtoint_Word"(%3 : $Builtin.RawPointer) : $Builtin.Word // user: %9 br bb1 // id: %6 bb1: // Preds: bb0 %7 = integer_literal $Builtin.Int8, 2 // user: %9 br bb2 // id: %8 bb2: // Preds: bb1 %9 = struct $StaticString (%5 : $Builtin.Word, %4 : $Builtin.Word, %7 : $Builtin.Int8) // user: %28 %1
Avatar
Avatar
koher 30-Sep-20 04:49 AM
@swift-nightly -Xfrontend -emit-sil -Xfrontend -enable-experimental-concurrency
struct Foo { init() async throws { fatalError() } }
(edited)
Avatar
swiftNightly BOT 30-Sep-20 04:49 AM
exit status: 1 with stderr:
<stdin>:2:12: error: initializer cannot be marked 'async' init() async throws { ^~~~~~
Avatar
kateinoigakukun 13-Oct-20 04:51 AM
@swift-nightly @swift-5.3.3 @swift-5.2.5 @swift-5.0.3 @swift-4.2.4
import Foundation @objc public protocol C { @objc optional var field1: ObjCBool { get set } } extension C { public func set(value: Bool) { self[keyPath: \C.field1] = ObjCBool(value) } }
Avatar
swift52 BOT 13-Oct-20 04:51 AM
exit status: 134 with stderr:
SIL verification failed: keypath value type should match value type of keypath pattern: leafTy == pattern->getValueType().subst(patternSubs)->getCanonicalType() Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil [ossa] @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 // users: %9, %2 // %1 // users: %4, %3 bb0(%0 : $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type /
Avatar
swift50 BOT 13-Oct-20 04:51 AM
exit status: 134 with stderr:
SIL verification failed: keypath value type should match value type of keypath pattern: leafTy == pattern->getValueType().subst(patternSubs)->getCanonicalType() Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 // users: %9, %2 // %1 // users: %4, %3 bb0(%0 : @trivial $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter.1 : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type
Avatar
swift53 BOT 13-Oct-20 04:51 AM
exit status: 134 with stderr:
SIL verification failed: keypath value type should match value type of keypath pattern Optional<ObjCBool> ObjCBool Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil [ossa] @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 "value" // users: %9, %2 // %1 "self" // users: %4, %3 bb0(%0 : $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type // user: %9 // function_ref ObjCBool.init(_:)
Avatar
swift42 BOT 13-Oct-20 04:51 AM
exit status: 1 with stderr:
<stdin>:5:9: error: property cannot be marked @objc because its type cannot be represented in Objective-C var field1: ObjCBool { get set } ^ ~~~~~~~~ <stdin>:5:17: note: Swift structs cannot be represented in Objective-C var field1: ObjCBool { get set } ^~~~~~~~
Avatar
swiftNightly BOT 13-Oct-20 04:51 AM
exit status: 134 with stderr:
SIL verification failed: keypath value type should match value type of keypath pattern Optional<ObjCBool> ObjCBool Verifying instruction: -> %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %16 = apply %15<C, Optional<ObjCBool>>(%11, %6, %13) : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed ReferenceWritableKeyPath<τ_0_0, τ_0_1>, @in τ_0_1) -> () destroy_value %6 : $ReferenceWritableKeyPath<C, Optional<ObjCBool>> // id: %20 In function: // C.set(value:) sil [ossa] @$s4main1CPAAE3set5valueySb_tF : $@convention(method) <Self where Self : C> (Bool, @guaranteed Self) -> () { // %0 "value" // users: %9, %2 // %1 "self" // users: %4, %3 bb0(%0 : $Bool, %1 : @guaranteed $Self): debug_value %0 : $Bool, let, name "value", argno 1 // id: %2 debug_value %1 : $Self, let, name "self", argno 2 // id: %3 %4 = copy_value %1 : $Self // user: %5 %5 = init_existential_ref %4 : $Self : $Self, $C // user: %12 %6 = keypath $ReferenceWritableKeyPath<C, Optional<ObjCBool>>, (root $C; settable_property $ObjCBool, id #C.field1!getter : <Self where Self : C> (Self) -> () -> ObjCBool, getter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTK : $@convention(thin) (@in_guaranteed C) -> @out ObjCBool, setter @$s4main1CP6field110Foundation8ObjCBoolVvpAaB_pTk : $@convention(thin) (@in_guaranteed ObjCBool, @in_guaranteed C) -> ()) // users: %20, %16 %7 = metatype $@thin ObjCBool.Type // user: %9 // function_ref ObjCBool.init(_:)
Avatar
nanasi 13-Oct-20 01:57 PM
@swift-nightly
class Foo<T> {} class Bar: Foo<Bar> {} func foo<F: Foo<F>>(_ foo: F) {}
Avatar
swiftNightly BOT 13-Oct-20 01:57 PM
exit status: 1 with stderr:
<stdin>:4:13: error: superclass constraint 'F' : 'Foo<F>' is recursive func foo<F: Foo<F>>(_ foo: F) {} ^
Avatar
koher 16-Oct-20 02:03 PM
@swift-nightly -Xfrontend -enable-experimental-concurrency
import Dispatch func suspendAsync<T>( _ body: (_ continuation: @escaping (T) -> ()) -> () ) async -> T { let semaphore = DispatchSemaphore(value: 0) var result: T! body { value in result = value semaphore.signal() } semaphore.wait() return result } extension DispatchQueue { func asyncAfter(deadline: DispatchTime) async { await suspendAsync { continuation in asyncAfter(deadline: deadline) { continuation(()) } } } } @asyncHandler func main() { print("A") await DispatchQueue.global().asyncAfter(deadline: .now() + 1) print("B") await DispatchQueue.global().asyncAfter(deadline: .now() + 1) print("C") } main()
Avatar
swiftNightly BOT 16-Oct-20 02:03 PM
A B C
Avatar
koher 19-Oct-20 10:32 AM
@swift-5.3.3 @swift-5.2.5
func primes(upTo number: Int) -> [Int] { precondition(number >= 0) if number < 2 { return [] } var sieve: [Bool] = .init(repeating: false, count: number + 1) for m in stride(from: 3, through: Int(Double(number).squareRoot() + 1.5), by: 2) { if sieve[m] { continue } let maxK = number / m if maxK < 2 { continue } for k in 2 ... maxK { sieve[k * m] = true } } var result: [Int] = [2] for m in stride(from: 3, through: number, by: 2) { if sieve[m] { continue } result.append(m) } return result } print(primes(upTo: 100))
Avatar
swift53 BOT 19-Oct-20 10:32 AM
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Avatar
swift52 BOT 19-Oct-20 10:32 AM
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Avatar
koher 19-Oct-20 10:34 AM
@swift-5.1.5
func primes(upTo number: Int) -> [Int] { precondition(number >= 0) if number < 2 { return [] } var sieve: [Bool] = .init(repeating: false, count: number + 1) for m in stride(from: 3, through: Int(Double(number).squareRoot() + 1.5), by: 2) { if sieve[m] { continue } let maxK = number / m if maxK < 2 { continue } for k in 2 ... maxK { sieve[k * m] = true } } var result: [Int] = [2] for m in stride(from: 3, through: number, by: 2) { if sieve[m] { continue } result.append(m) } return result } print(primes(upTo: 100))
Avatar
swift51 BOT 19-Oct-20 10:34 AM
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Avatar
koher 22-Oct-20 02:46 PM
@swift-5.2.5
print("Hello, World!")
Avatar
swift52 BOT 22-Oct-20 02:46 PM
Hello, World!
Avatar
norio_nomura 13-Nov-20 12:49 AM
@swift-5.3.3 -version
Avatar
swift53 BOT 13-Nov-20 12:49 AM
Swift version 5.3.1 (swift-5.3.1-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
swift53 BOT 04-Dec-20 09:38 AM
execution timeout with no output
👀 1
Avatar
koher 04-Dec-20 09:40 AM
@swift-5.3.3 -O
import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } extension Array { mutating func mySwapAt(_ i: Int, _ j: Int) { let t = self[i] self[i] = self[j] self[j] = t } } func swapBySwapAt(_ array: inout [Int]) { for i in array.indices.dropFirst() { array.swapAt(i - 1, i) } } func swapByT(_ array: inout [Int]) { for i in array.indices.dropFirst() { let t = array[i] array[i] = array[i - 1] array[i - 1] = t } } func swapByMySwapAt(_ array: inout [Int]) { for i in array.indices.dropFirst() { array.mySwapAt(i - 1, i) } } let n: Int = 10_000_000 + (1 ... 100).randomElement()! var a: [Int] = Array(1 ... n) measure { swapBySwapAt(&a) } measure { swapByT(&a) } measure { swapByMySwapAt(&a) } print(a.count)
Avatar
swift53 BOT 04-Dec-20 09:40 AM
0.07282540798187256 0.07877689599990845 0.0749101996421814 10000014
Avatar
koher 04-Dec-20 09:41 AM
手元と結果が違うw
Avatar
omochimetaru 04-Dec-20 09:41 AM
Linuxだから?
あーでもArrayなのか
Foudationの違いは関係無さそうだ (edited)
Avatar
koher 04-Dec-20 09:42 AM
手元環境だと swapBySwapAt が 10% くらい遅いんだけどなぁ。
Avatar
omochimetaru 04-Dec-20 09:43 AM
CPUの違いでベクトル最適化が効いたり効かなかったりとかもあるかも
Avatar
koher 04-Dec-20 09:47 AM
トピックが一つ死んだ😢
Avatar
koher 04-Dec-20 09:56 AM
@swift-5.3.3 -O
import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } func mapFilter(_ n: Int) -> [Int] { precondition(n >= 1) return (1 ... n).map { $0 * $0 }.filter { $0 % 7 == 1 } } func lazyMapFilter(_ n: Int) -> [Int] { precondition(n >= 1) return Array((1 ... n).lazy.map { $0 * $0 }.filter { $0 % 7 == 1 }) } func mapFilterByLoop(_ n: Int) -> [Int] { precondition(n >= 1) var result: [Int] = [] for i in 1 ... n { let square = i * i guard square % 7 == 1 else { continue } result.append(square) } return result } let n: Int = 10_000_000 + (1 ... 100).randomElement()! var a = 0 measure { a += mapFilter(n).count } measure { a += lazyMapFilter(n).count } measure { a += mapFilterByLoop(n).count } print(a)
Avatar
swift53 BOT 04-Dec-20 09:56 AM
0.5088738918304443 0.09912219047546386 0.09465489387512208 85715100
Avatar
koher 04-Dec-20 10:00 AM
@swift-5.3.3 -O
import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } func sumOfArray(_ a: [Int], indices: [Int]) -> Int { var sum = 0 for i in indices { sum &+= a[i] } return sum } func sumOfArraySlice(_ a: ArraySlice<Int>, indices: [Int]) -> Int { var sum = 0 for i in indices { sum &+= a[i] } return sum } let n: Int = 1_000_000 + (1 ... 100).randomElement()! let a: [Int] = .init(1 ... n) let b: ArraySlice<Int> = .init(a) let indices: [Int] = a.indices.shuffled() var sum = 0 measure { sum &+= sumOfArray(a, indices: indices) } measure { sum &+= sumOfArraySlice(b, indices: indices) } print(sum)
Avatar
swift53 BOT 04-Dec-20 10:00 AM
0.02275540828704834 0.022072792053222656 10002010101000
Avatar
omochimetaru 04-Dec-20 10:00 AM
なんかいろいろでてくる
Avatar
koher 04-Dec-20 10:04 AM
@swift-5.3.3 -O
import Foundation func measure(_ body: () -> Void) { let start = Date.timeIntervalSinceReferenceDate for _ in 0 ..< 10 { body() } let end = Date.timeIntervalSinceReferenceDate print((end - start) / 10) } public func sumOfEvensByStride(_ n: Int) -> Int { var sum = 0 for m in stride(from: 0, through: n * 2, by: 2) { sum &+= m } return sum } public func sumOfEvensByRange(_ n: Int) -> Int { var sum = 0 for m in 0 ... n { sum &+= m * 2 } return sum } public func sumOfMultiplesByStride(_ n: Int, k: Int) -> Int { var sum = 0 for m in stride(from: 0, through: n * k, by: k) { sum &+= m } return sum } public func sumOfMultiplesByRange(_ n: Int, k: Int) -> Int { var sum = 0 for m in 0 ... n { sum &+= m * k } return sum } let n = 100_000_000 + (1 ... 100).randomElement()! var a = 0 measure { a &+= sumOfEvensByStride(n) } measure { a &+= sumOfEvensByRange(n) } measure { a &+= sumOfMultiplesByStride(n, k: 3) } measure { a &+= sumOfMultiplesByRange(n, k: 3) } print(a)
Avatar
swift53 BOT 04-Dec-20 10:04 AM
0.1298200011253357 0.0950276017189026 0.09767409563064575 0.09397300481796264 500000385000074100
Avatar
norio_nomura 13-Dec-20 11:01 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
// Ported from https://www.raywenderlich.com/741-swift-algorithm-club-swift-merge-sort func mergeSort<T: Comparable>(_ array: [T]) async -> [T] { guard array.count > 1 else { return array } let middleIndex = array.count / 2 async let leftArray = await mergeSort(Array(array[0..<middleIndex])) async let rightArray = await mergeSort(Array(array[middleIndex..<array.count])) return merge(await leftArray, await rightArray) } func merge<T: Comparable>(_ left: [T], _ right: [T]) -> [T] { var leftIndex = 0 var rightIndex = 0 var orderedArray: [T] = [] while leftIndex < left.count && rightIndex < right.count { let leftElement = left[leftIndex] let rightElement = right[rightIndex] if leftElement < rightElement { orderedArray.append(leftElement) leftIndex += 1 } else if leftElement > rightElement { orderedArray.append(rightElement) rightIndex += 1 } else { orderedArray.append(leftElement) leftIndex += 1 orderedArray.append(rightElement) rightIndex += 1 } } while leftIndex < left.count { orderedArray.append(left[leftIndex]) leftIndex += 1 } while rightIndex < right.count { orderedArray.append(right[rightIndex]) rightIndex += 1 } return orderedArray } func getRandomArray(n: Int) -> [Int] { var array = [Int]() for i in 0..<n { array.append(Int.random(in: 0..<1000)) } return array } func test(n: Int) async { let array = getRandomArray(n: n) let sortedArray = await mergeSort(array) print(sortedArray) } runAsyncAndBlock { await test(n: 100) }
(edited)
Avatar
swiftNightly BOT 13-Dec-20 11:01 AM
[2, 19, 20, 28, 28, 52, 67, 69, 72, 89, 91, 103, 104, 106, 116, 125, 165, 175, 184, 187, 196, 198, 208, 211, 214, 235, 243, 247, 248, 251, 268, 293, 306, 309, 312, 321, 339, 339, 345, 364, 393, 396, 404, 406, 420, 425, 434, 446, 453, 455, 474, 478, 480, 483, 485, 487, 488, 493, 499, 511, 520, 528, 543, 604, 628, 636, 645, 650, 650, 666, 670, 673, 678, 690, 713, 716, 720, 721, 723, 730, 761, 764, 797, 811, 819, 832, 834, 839, 843, 844, 860, 885, 905, 916, 925, 931, 942, 959, 959, 986]
stderr:
<stdin>:52:7: warning: immutable value 'i' was never used; consider replacing with '_' or removing it for i in 0..<n { ^ _
(edited)
Avatar
norio_nomura 24-Dec-20 11:32 PM
5.4のスナップショットは年内に出始めそう。 https://ci.swift.org/view/Swift%205.4/
Avatar
norio_nomura 09-Jan-21 01:31 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
// // main.swift // ConcurrencyPlayground // // Created by Max Desiatov on 07/01/2021. // import _Concurrency import Foundation import FoundationNetworking struct UnknownError: Error {} func download(url: URL) async throws -> Data { try await withUnsafeThrowingContinuation { c in let task = URLSession.shared.dataTask(with: url) { data, _, error in switch (data, error) { case let (_, error?): return c.resume(throwing: error) case let (data?, _): return c.resume(returning: data) case (nil, nil): c.resume(throwing: UnknownError()) } } task.resume() } } runAsyncAndBlock { print("task started") let data = try! await download(url: URL(string: "https://httpbin.org/uuid")!) print(String(data: data, encoding: .utf8)!) } print("end of main")
(edited)
Avatar
swiftNightly BOT 09-Jan-21 01:31 AM
task started end of main
Avatar
swiftNightly BOT 11-Jan-21 12:08 PM
exit status: 11 with stderr:
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. /usr/bin/swift-frontend[0x56a4d34] /usr/bin/swift-frontend[0x56a2bb0] /usr/bin/swift-frontend[0x56a4f1a] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f6d470ce390] /lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7f6d45a89746] /lib/x86_64-linux-gnu/libc.so.6(__strdup+0xe)[0x7f6d45a8947e] /usr/lib/x86_64-linux-gnu/libcurl.so.4(+0x1de88)[0x7f6d3e9dde88] /usr/lib/x86_64-linux-gnu/libcurl.so.4(curl_easy_setopt+0x9e)[0x7f6d3e9ed8ae] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking11_EasyHandleC3set3urly0A03URLV_tF+0xcc)[0x7f6d3ed25afc] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking16_HTTPURLProtocolC19configureEasyHandle3for4bodyyAA10URLRequestV_AA14URLSessionTaskC5_BodyOtF+0x230)[0x7f6d3ecf65f0] /usr/lib/swift/linux/libFoundationNetworking.so(+0xd5bb3)[0x7f6d3ed04bb3] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking14URLSessionTaskC7getBody10completionyyAC01_F0Oc_tF+0x128)[0x7f6d3ed14a48] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking15_NativeProtocolC16startNewTransfer4withyAA10URLRequestV_tF+0xe1)[0x7f6d3ed02041] /usr/lib/swift/linux/libFoundationNetworking.so($s20FoundationNetworking15_NativeProtocolC6resumeyyF+0x28a)[0x7f6d3ed0233a] /usr/lib/swift/linux/libFoundationNetworking.so(+0xf04c7)[0x7f6d3ed1f4c7] /usr/lib/swift/linux/libFoundationNetworking.so(+0xa0c59)[0x7f6d3eccfc59] /usr/lib/swift/linux/libdispatch.so(+0x224e7)[0x7f6d3ef8d4e7] /usr/lib/swift/linux/libdispatch.so(+0x2de39)[0x7f6d3ef98e39] /usr/lib/swift/linux/libdispatch.so(+0x2eade)[0x7f6d3ef99ade] /usr/lib/swift/linux/libdispatch.so(+0x2dcd4)[0x7f6d3ef98cd4] /usr/lib/swift/linux/libdispatch.so(+0x2eade)[0x7f6d3ef99ade] /usr/lib/swift/linux/libdispatch.so(+0x36752)[0x7f6d3efa1752] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f6d470c46ba] /li
Avatar
norio_nomura 13-Jan-21 12:52 AM
@swift-5.4.3 -version
Avatar
swift54 BOT 13-Jan-21 12:52 AM
Swift version 5.3-dev (LLVM 52eb795d06cc2c1, Swift eb8c8ecef009d64) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 13-Jan-21 12:55 AM
@swift-5.4.3
import Foundation print(ProcessInfo.processInfo.environment["SWIFT_VERSION"]!)
Avatar
swift54 BOT 13-Jan-21 12:55 AM
5.4-DEVELOPMENT-SNAPSHOT-2021-01-11-a
Avatar
norio_nomura 13-Jan-21 12:57 AM
@swift-5.4.3 -Xfrontend -enable-experimental-concurrency
// // main.swift // ConcurrencyPlayground // // Created by Max Desiatov on 07/01/2021. // import _Concurrency import Foundation import FoundationNetworking struct UnknownError: Error {} func download(url: URL) async throws -> Data { await try withUnsafeThrowingContinuation { c in let task = URLSession.shared.dataTask(with: url) { data, _, error in switch (data, error) { case let (_, error?): return c.resume(throwing: error) case let (data?, _): return c.resume(returning: data) case (nil, nil): c.resume(throwing: UnknownError()) } } task.resume() } } runAsyncAndBlock { print("task started") let data = await try! download(url: URL(string: "https://httpbin.org/uuid")!) print(String(data: data, encoding: .utf8)!) } print("end of main")
(edited)
Avatar
swift54 BOT 13-Jan-21 12:57 AM
task started end of main
(edited)
Avatar
koher 22-Jan-21 07:34 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
print(Task.self)
Avatar
swiftNightly BOT 22-Jan-21 07:34 AM
Task
Avatar
omochimetaru 22-Jan-21 07:35 AM
おお。居る。
Avatar
koher 22-Jan-21 07:36 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
print(await Task.currentPriority())
Avatar
swiftNightly BOT 22-Jan-21 07:36 AM
exit status: 1 with stderr:
<stdin>:1:13: error: 'async' in a function that does not support concurrency print(await Task.currentPriority()) ^
Avatar
koher 22-Jan-21 07:37 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
print(Task.userInteractive)
Avatar
swiftNightly BOT 22-Jan-21 07:37 AM
exit status: 1 with stderr:
<stdin>:1:12: error: type 'Task' has no member 'userInteractive' print(Task.userInteractive) ~~~~ ^~~~~~~~~~~~~~~
Avatar
koher 22-Jan-21 07:38 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
print(Task.Priority.self)
(edited)
Avatar
swiftNightly BOT 22-Jan-21 07:38 AM
Priority
Avatar
koher 22-Jan-21 07:39 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
print(Task.Priority.init(rawValue: 0)!)
Avatar
swiftNightly BOT 22-Jan-21 07:39 AM
unspecified
Avatar
koher 22-Jan-21 07:39 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
print(Task.Priority.init(rawValue: 1)!)
Avatar
swiftNightly BOT 22-Jan-21 07:39 AM
exit status: 4 with stderr:
main/<stdin>:1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Current stack trace: 0 libswiftCore.so 0x00007f8d025ef150 swift_reportError + 50 1 libswiftCore.so 0x00007f8d026638f0 _swift_stdlib_reportFatalErrorInFile + 112 2 libswiftCore.so 0x00007f8d02343de6 <unavailable> + 1433062 3 libswiftCore.so 0x00007f8d02343a0f <unavailable> + 1432079 4 libswiftCore.so 0x00007f8d023437ac <unavailable> + 1431468 5 libswiftCore.so 0x00007f8d023432c0 _assertionFailure(_:_:file:line:flags:) + 441 7 swift-frontend 0x0000000000597635 <unavailable> + 1668661 8 swift-frontend 0x000000000056102e <unavailable> + 1445934 9 swift-frontend 0x000000000052c442 <unavailable> + 1229890 10 swift-frontend 0x000000000052baac <unavailable> + 1227436 11 swift-frontend 0x000000000051ee4d <unavailable> + 1175117 12 swift-frontend 0x00000000004b8f78 <unavailable> + 757624 13 libc.so.6 0x00007f8d0462a740 __libc_start_main + 240 14 swift-frontend 0x00000000004b8a49 <unavailable> + 756297 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build
Avatar
koher 22-Jan-21 08:02 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
let handle: Task.Handle<Int, Never> = Task.runDetached { 42 } print(await handle.get())
(edited)
Avatar
swiftNightly BOT 22-Jan-21 08:03 AM
exit status: 1 with stderr:
<stdin>:1:18: error: generic type 'Handle' specialized with too many type parameters (got 2, but expected 1) let handle: Task.Handle<Int, Never> = Task.runDetached { 42 } ^ ~~~~~~~~~~~~ _Concurrency.Task:2:19: note: generic type 'Handle' declared here public struct Handle<Success> { ^
Avatar
koher 22-Jan-21 08:03 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
let handle: Task.Handle<Int> = Task.runDetached { 42 } print(try await handle.get())
(edited)
Avatar
swiftNightly BOT 22-Jan-21 08:03 AM
exit status: 1 with stderr:
<stdin>:2:17: error: 'async' in a function that does not support concurrency print(try await handle.get()) ^
(edited)
Avatar
koher 22-Jan-21 08:06 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
_ = Task.runDetached { 42 }
Avatar
swiftNightly BOT 22-Jan-21 08:06 AM
no output
Avatar
koher 22-Jan-21 08:08 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
func foo() async -> Int { 42 } @asyncHandler func bar() { let a = await foo() print(a) }
Avatar
swiftNightly BOT 22-Jan-21 08:08 AM
no output
Avatar
koher 22-Jan-21 08:43 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
func foo() async -> Int { 3 } func main() async { async let a = foo() async let b = foo() print(await a + b) }
Avatar
swiftNightly BOT 22-Jan-21 08:43 AM
no output
Avatar
kateinoigakukun 22-Jan-21 02:09 PM
@swift-nightly -Xfrontend -enable-experimental-concurrency
func foo() async -> Int { 3 } func main() async { async let a = foo() async let b = foo() print(await a + b) } runAsyncAndBlock { await main() }
(edited)
Avatar
swiftNightly BOT 22-Jan-21 02:09 PM
6
Avatar
norio_nomura 25-Jan-21 11:57 PM
@swift-nightly @swift-5.4.3 -Xfrontend -enable-experimental-concurrency
func f() async throws -> Int { 1 } func g() async throws -> Int { let a = try await f() let b = await try f() return a + b }
Avatar
swiftNightly BOT 25-Jan-21 11:57 PM
stderr:
<stdin>:4:13: warning: 'try' must precede 'await' let b = await try f() ^~~~~~ await
Avatar
swift54 BOT 25-Jan-21 11:57 PM
exit status: 1 with stderr:
<stdin>:3:17: error: 'await' must precede 'try' let a = try await f() ^~~~~~ await
Avatar
koher 26-Jan-21 01:31 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
func foo() async -> Int { 42 } runAsyncAndBlock { await foo() }
(edited)
Avatar
swiftNightly BOT 26-Jan-21 01:31 AM
stderr:
<stdin>:2:26: warning: result of call to 'foo()' is unused runAsyncAndBlock { await foo() } ^ ~~
Avatar
ataka 26-Jan-21 01:38 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
Avatar
swiftNightly BOT 26-Jan-21 01:38 AM
exit status: 127 with stderr:
/usr/bin/lldb: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Avatar
ataka 26-Jan-21 01:38 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
import Foundation import FoundationNetworking struct User: Identifiable, Codable { typealias ID = Int let id: ID var name: String var thumbnailURL: URL } func download(from url: URL, completion: @escaping (Data) -> Void) { let data: Data = try! Data(contentsOf: url) completion(data) } func fetchUser(for id: User.ID, completion: @escaping (User) -> Void) { let url: URL = URL(string: "https://koherent.org/async-await-challenge/api/user?id=\(id.description)")! download(from: url) { data in let user = try! JSONDecoder().decode(User.self, from: data) completion(user) } } fetchUser(for: 123) { user in print(user.name) }
Avatar
swiftNightly BOT 26-Jan-21 01:38 AM
koher
Avatar
monolithic-adam 26-Jan-21 01:39 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
import Foundation struct User: Identifiable, Codable { typealias ID = Int let id: ID var name: String var thumbnailURL: URL } func download(from url: URL) async -> Data { let data: Data = try! Data(contentsOf: url) return data } func fetchUser(for id: User.ID) async -> User { let url: URL = URL(string: "https://koherent.org/async-await-challenge/api/user?id=\(id.description)")! let data = await download(from: url) let user = try! JSONDecoder().decode(User.self, from: data) return user } runAsyncAndBlock { let user = await fetchUser(for: 123) print(user.name) }
(edited)
Avatar
swiftNightly BOT 26-Jan-21 01:39 AM
exit status: 4 with stderr:
Foundation/NSSwiftRuntime.swift:401: Fatal error: You must link or load module FoundationNetworking to load non-file: URL content using String(contentsOf:…), Data(contentsOf:…), etc. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -enable-experimental-concurrency -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-li
(edited)
Avatar
ataka 26-Jan-21 01:40 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency
import Foundation import FoundationNetworking struct User: Identifiable, Codable { typealias ID = Int let id: ID var name: String var thumbnailURL: URL } func download(from url: URL) async -> Data { let data: Data = try! Data(contentsOf: url) return data } func fetchUser(for id: User.ID) async -> User { let url: URL = URL(string: "https://koherent.org/async-await-challenge/api/user?id=\(id.description)")! let data = await download(from: url) return try! JSONDecoder().decode(User.self, from: data) } runAsyncAndBlock { let user = await fetchUser(for: 123) print(user.name) }
Avatar
swiftNightly BOT 26-Jan-21 01:40 AM
koher
Avatar
t.ae 22-Feb-21 08:31 AM
@swift-5.3.3
import Foundation extension Process { struct RunResult { var output: Data var error: Data var status: Int32 } static func which(_ i: Int) throws -> RunResult { let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/which") p.arguments = ["which"] let g = DispatchGroup() var outData = Data() let outPipe = Pipe() p.standardOutput = outPipe g.enter() outPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData outData.append(availableData) print("[\(i)] stdout \(availableData)") if availableData.isEmpty { outPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } var errData = Data() let errPipe = Pipe() p.standardError = errPipe g.enter() errPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData errData.append(availableData) print("[\(i)] stderr \(availableData)") if availableData.isEmpty { errPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } try p.run() p.waitUntilExit() print("[\(i)] process end") guard case .success = g.wait(timeout: .now()+3) else { fatalError("[\(i)] timeout") } print("[\(i)] wait end") let status = p.terminationStatus let result = RunResult(output: outData, error: errData, status: status) print("[\(i)] end output=\(result.output) error=\(result.error)") return result } } DispatchQueue.concurrentPerform(iterations: 3) { i in _ = try! Process.which(i) } print("end")
Avatar
swift53 BOT 22-Feb-21 08:31 AM
exit status: 4 with stderr:
Fatal error: [1] timeout: file main/<stdin>, line 46 Fatal error: [2] timeout: file main/<stdin>, line 46 Current stack trace: Current stack trace: Fatal error: [0] timeout: file main/<stdin>, line 46 Current stack trace: 0 libswiftCore.so 0x00007f76f2276df0 swift_reportError + 50 1 libswiftCore.so 0x00007f76f22ea160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007f76f1fcfeb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007f76f1fcfaf7 <unavailable> + 1399543 4 libswiftCore.so 0x00007f76f1fd00e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007f76f1fce530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007f76ee5f2bf1 <unavailable> + 117745 9 libswiftDispatch.so 0x00007f76ee5f2c14 <unavailable> + 117780 10 libdispatch.so 0x00007f76ee39560e <unavailable> + 128526 11 libdispatch.so 0x00007f76ee3ac787 <unavailable> + 223111 12 libpthread.so.0 0x00007f76f66ed6ba <unavailable> + 30394 13 libc.so.6 0x00007f76f4ef63b0 clone + 109 0 libswiftCore.so 0x00007f76f2276df0 swift_reportError + 50 0 libswiftCore.so 0x00007f76f2276df0 swift_reportError + 50 1 libswiftCore.so 0x00007f76f22ea160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007f76f1fcfeb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007f76f1fcfaf7 <unavailable> + 1399543 4 libswiftCore.so 0x00007f76f1fd00e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007f76f1fce530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007f76ee5f2bf1 <unavailable> + 117745 9 libswiftDispatch.so
Avatar
Iceman 22-Feb-21 08:43 AM
@swift-5.3.3
import Foundation extension Process { struct RunResult { var output: Data var error: Data var status: Int32 } static func which(_ i: Int) throws -> RunResult { let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/which") p.arguments = ["which"] let g = DispatchGroup() var outData = Data() let outPipe = Pipe() p.standardOutput = outPipe g.enter() outPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData outData.append(availableData) print("[\(i)] stdout \(availableData)") if availableData.isEmpty { outPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } var errData = Data() let errPipe = Pipe() p.standardError = errPipe g.enter() errPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData errData.append(availableData) print("[\(i)] stderr \(availableData)") if availableData.isEmpty { errPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } try p.run() p.waitUntilExit() print("[\(i)] process end") guard case .success = g.wait(timeout: .now()+3) else { fatalError("[\(i)] timeout") } print("[\(i)] wait end") let status = p.terminationStatus let result = RunResult(output: outData, error: errData, status: status) print("[\(i)] end output=\(result.output) error=\(result.error)") return result } } DispatchQueue.concurrentPerform(iterations: 1) { i in _ = try! Process.which(i) } print("end")
Avatar
swift53 BOT 22-Feb-21 08:43 AM
exit status: 4 with stderr:
Fatal error: [0] timeout: file main/<stdin>, line 46 Current stack trace: 0 libswiftCore.so 0x00007fe78a46edf0 swift_reportError + 50 1 libswiftCore.so 0x00007fe78a4e2160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fe78a1c7eb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007fe78a1c7af7 <unavailable> + 1399543 4 libswiftCore.so 0x00007fe78a1c80e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007fe78a1c6530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007fe7867eabf1 <unavailable> + 117745 9 libswiftDispatch.so 0x00007fe7867eac14 <unavailable> + 117780 10 libdispatch.so 0x00007fe78658df60 <unavailable> + 130912 11 libdispatch.so 0x00007fe7865993aa <unavailable> + 177066 12 libdispatch.so 0x00007fe78658da40 dispatch_apply_f + 1044 13 libswiftDispatch.so 0x00007fe7867eaaa0 static DispatchQueue.concurrentPerform(iterations:execute:) + 204 15 swift 0x00000000005b4501 <unavailable> + 1787137 16 swift 0x00000000005a1d04 <unavailable> + 1711364 17 swift 0x0000000000587e88 <unavailable> + 1605256 18 swift 0x000000000057b322 <unavailable> + 1553186 19 swift 0x00000000005780ef <unavailable> + 1540335 20 swift 0x0000000000501c2c <unavailable> + 1055788 21 libc.so.6 0x00007fe78d007740 __libc_start_main + 240 22 swift 0x00000000005017a9 <unavailable> + 1054633 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libr
Avatar
t.ae 22-Feb-21 09:05 AM
@swift-5.3.3
import Foundation func print(_ item: String) { fputs(item + "\n", stderr) } extension Process { struct RunResult { var output: Data var status: Int32 } static func which(_ i: Int) throws -> RunResult { let p = Process() p.executableURL = URL(fileURLWithPath: "/usr/bin/which") p.arguments = ["which"] let g = DispatchGroup() var outData = Data() let outPipe = Pipe() p.standardOutput = outPipe g.enter() outPipe.fileHandleForReading.readabilityHandler = { (handle) in let availableData = handle.availableData outData.append(availableData) print("[\(i)] stdout \(availableData)") if availableData.isEmpty { outPipe.fileHandleForReading.readabilityHandler = nil g.leave() } } try p.run() p.waitUntilExit() print("[\(i)] process end") guard case .success = g.wait(timeout: .now()+3) else { fatalError("[\(i)] timeout") } print("[\(i)] wait end") let status = p.terminationStatus let result = RunResult(output: outData, status: status) print("[\(i)] end output=\(result.output)") return result } } DispatchQueue.concurrentPerform(iterations: 3) { i in _ = try! Process.which(i) } print("end")
Avatar
swift53 BOT 22-Feb-21 09:05 AM
exit status: 4 with stderr:
[2] process end [0] stdout 15 bytes [2] stdout 15 bytes [1] process end [1] stdout 15 bytes [0] process end Fatal error: [2] timeout: file main/<stdin>, line 34 Current stack trace: 0 libswiftCore.so 0x00007fbd21293df0 swift_reportError + 50 1 libswiftCore.so 0x00007fbd21307160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fbd20feceb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007fbd20fecaf7 <unavailable> + 1399543 4 libswiftCore.so 0x00007fbd20fed0e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007fbd20feb530 _assertionFailure(_:_:file:line:flags:) + 517 8 libswiftDispatch.so 0x00007fbd1d60fbf1 <unavailable> + 117745 9 libswiftDispatch.so 0x00007fbd1d60fc14 <unavailable> + 117780 10 libdispatch.so 0x00007fbd1d3b260e <unavailable> + 128526 11 libdispatch.so 0x00007fbd1d3c9787 <unavailable> + 223111 12 libpthread.so.0 0x00007fbd2570a6ba <unavailable> + 30394 13 libc.so.6 0x00007fbd23f133b0 clone + 109 /usr/bin/swift[0x50aee34] /usr/bin/swift[0x50ace00] /usr/bin/swift[0x50af11a] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fbd25714390] /usr/lib/swift/linux/libswiftCore.so($ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF+0x212)[0x7fbd20feb742] [0x7fbd2594de50] [0x7fbd2594e209] /usr/lib/swift/linux/libswiftDispatch.so(+0x1cbf1)[0x7fbd1d60fbf1] /usr/lib/swift/linux/libswiftDispatch.so(+0x1cc14)[0x7fbd1d60fc14] /usr/lib/swift/linux/libdispatch.so(+0x1f60e)[0x7fbd1d3b260e] /usr/lib/swift/linux/libdispatch.so(+0x36787)[0x7fbd1d3c9787] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7fbd2570a6ba] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fbd23f1341d]
Avatar
norio_nomura 23-Feb-21 10:51 AM
@swift-nightly -Xfrontend -enable-experimental-concurrency -Xfrontend -parse-as-library
// // main.swift // ConcurrencyPlayground // // Created by Max Desiatov on 07/01/2021. // import Foundation import FoundationNetworking struct UnknownError: Error {} func download(url: URL) async throws -> Data { try await withUnsafeThrowingContinuation { c in let task = URLSession.shared.dataTask(with: url) { data, _, error in switch (data, error) { case let (_, error?): return c.resume(throwing: error) case let (data?, _): return c.resume(returning: data) case (nil, nil): c.resume(throwing: UnknownError()) } } task.resume() } } @main struct Main { static func main() async { print("task started") let data = try! await download(url: URL(string: "https://httpbin.org/uuid")!) print(String(data: data, encoding: .utf8)!) } }
Avatar
swiftNightly BOT 23-Feb-21 10:51 AM
task started { "uuid": "791fc520-32b9-40a9-bf49-77ca7f8e2d4e" }
Avatar
koher 24-Feb-21 02:29 AM
お、 Linux でもちゃんと並行に動くようになったんですか?
あ、 #swift の方でその話題 https://discord.com/channels/291054398077927425/291054454793306112/813681284592828427 になってた。 (edited)
Avatar koher
あ、 #swift の方でその話題 https://discord.com/channels/291054398077927425/291054454793306112/813681284592828427 になってた。 (edited)
Avatar
Kishikawa Katsumi 24-Feb-21 05:14 AM
そうそう。できるようになったので前に作られてたBefore/Afterの例とかすごくわかりやすかったのでよかったらシェアしてください 🙏🏼
Avatar
treastrain / Tanaka.R 05-Mar-21 05:07 AM
@swift-5.3.3
import Foundation let formatter = NumberFormatter() formatter.numberStyle = .decimal print("1:", formatter.string(from: 100)) // Optional("100") formatter.formatWidth = 6 print("2:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .beforePrefix print("3:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .afterPrefix print("4:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .beforeSuffix print("5:", formatter.string(from: 100)) // Optional("100 ") formatter.paddingPosition = .afterSuffix print("6:", formatter.string(from: 100)) // Optional("100 ")
(edited)
Avatar
swift53 BOT 05-Mar-21 05:07 AM
1: Optional("100") 2: Optional(" 100") 3: Optional(" 100") 4: Optional(" 100") 5: Optional("100 ") 6: Optional("100 ")
stderr:
<stdin>:5:13: warning: expression implicitly coerced from 'String?' to 'Any' print("1:", formatter.string(from: 100)) // Optional("100") ^~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:5:23: note: provide a default value to avoid this warning print("1:", formatter.string(from: 100)) // Optional("100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:5:23: note: force-unwrap the value to avoid this warning print("1:", formatter.string(from: 100)) // Optional("100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ! <stdin>:5:23: note: explicitly cast to 'Any' with 'as Any' to silence this warning print("1:", formatter.string(from: 100)) // Optional("100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ as Any <stdin>:8:13: warning: expression implicitly coerced from 'String?' to 'Any' print("2:", formatter.string(from: 100)) // Optional(" 100") ^~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:8:23: note: provide a default value to avoid this warning print("2:", formatter.string(from: 100)) // Optional(" 100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:8:23: note: force-unwrap the value to avoid this warning print("2:", formatter.string(from: 100)) // Optional(" 100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ ! <stdin>:8:23: note: explicitly cast to 'Any' with 'as Any' to silence this warning print("2:", formatter.string(from: 100)) // Optional(" 100") ~~~~~~~~~~^~~~~~~~~~~~~~~~~ as Any <stdin>:11:13: warning: expression implicitly coerced from 'String?' to 'Any' print("3:", formatter.string(from: 100)) // Optional(" 100") ^~~~~
(edited)
Avatar
omochimetaru 12-Mar-21 05:07 AM
@swift-5.3.3
import Foundation struct A: Encodable { var a1: Int = 1 var a2: Int = 2 } struct B: Encodable { var b1: Int = 3 var b2: Int = 4 } struct AAndB: Encodable { var a: A = .init() var b: B = .init() func encode(to encoder: Encoder) throws { try a.encode(to: encoder) try b.encode(to: encoder) } // func encode(to encoder: Encoder) throws { // do { // var c = encoder.singleValueContainer() // try c.encode(a) // } // do { // var c = encoder.singleValueContainer() // try c.encode(b) // } // } } func main() throws { let x = AAndB() let e = JSONEncoder() let j = try e.encode(x) print(String(decoding: j, as: UTF8.self)) } try! main()
Avatar
swift53 BOT 12-Mar-21 05:07 AM
{"a2":2,"b1":3,"a1":1,"b2":4}
Avatar
rintaro 15-Mar-21 11:20 PM
https://forums.swift.org/t/array-compiles-to-array-of-type/45742 @swift-5.3.3
let foo = Array {} print(type(of: foo))
So I just found this out. Not sure if it's a bug or somehow expected behavior. let foo = Array {} The code above works, and foo is inferred to be of type Array<() -> ()> aka [() -> ()] with a single element inside: an empty closure () -> () (which I assume is our {}). Digging deeper into which initializer is responsible for the instantiation,...
Avatar
swift53 BOT 15-Mar-21 11:20 PM
Array<() -> ()>
(edited)
Avatar
omochimetaru 16-Mar-21 04:34 AM
www
Avatar
koher 16-Mar-21 04:45 AM
この前のwaiwaiでも話題になった、 Trailing Closure のラベル省略が良くない事例だと思う。
Avatar
omochimetaru 16-Mar-21 04:46 AM
init(arrayLiteral:) って Array Literal 用のinitだから、
リテラルが書いてある場合もしくは、ラベルが書かれている場合しか、解決しないのが良さそう?
ラベルが書かれていない場合、というケースはTrailing Closureを使ったときしか生じないだろうけど。
Avatar
koher 16-Mar-21 04:49 AM
うん。普通はラベルがあるから意味わかるんだけど、 Trailing Closure になるとラベルが省略されて意味わからんくなってる。
Avatar
omochimetaru 16-Mar-21 04:49 AM
意味わからなくなるのは幅広い問題ですね。
Avatar
koher 16-Mar-21 04:49 AM
↓なら問題ないはず。
let foo = Array arrayLiteral: {}
Avatar
omochimetaru 16-Mar-21 04:49 AM
それってIDEが解決するのは駄目なんだろうか
今年のGSoCのテーマにもなってて。
テキストデータとして書かれてなくても arrayLiteral: が Xcodeによって表示されてれば、問題は解決する。
Avatar
koher 16-Mar-21 04:50 AM
source breaking すぎてもはや↑の変更はできないだろうけど、ラベルを許す、ラベルなしは警告とかならできそう。
Avatar
omochimetaru 16-Mar-21 04:51 AM
警告じゃなくてGUI上で表示しちゃう。
型推論の結果とかもそうする。
Avatar
koher 16-Mar-21 04:51 AM
テキストデータとして書かれてなくても arrayLiteral: が Xcodeによって表示されてれば、問題は解決する。
現状としてはラベルがある場合は Trailing Closure を IDE がオススメしないのがいいんじゃない?
Avatar
Kishikawa Katsumi 16-Mar-21 04:51 AM
JetBrains方式っすね
Avatar
omochimetaru 16-Mar-21 04:52 AM
今だと 変数名を Alt + Click で表示だけど、そうじゃなくて、エディタがインラインテキストをさしこむかんじ。
Avatar
koher 16-Mar-21 04:52 AM
Multiple Trailing Closure で最初のラベル省略が普通に使われてるから難しいかなぁ。
Avatar Kishikawa Katsumi
JetBrains方式っすね
Avatar
omochimetaru 16-Mar-21 04:52 AM
はい。Kotlinはそうなってますね。なんかRustもそうなってきたらしくて。
Avatar
Kishikawa Katsumi 16-Mar-21 04:52 AM
実際のコードをそうした方がというのは思うけどIDEがそういうサポートを入れるのはそれはそれでかなり良いと思います。
Avatar
koher 16-Mar-21 04:52 AM
それってラベルが言語機能である Swift と相性悪くないかなぁ。本物ラベルのときと IDE 挿入のときがあるわけで。
Avatar
Kishikawa Katsumi 16-Mar-21 04:53 AM
それは表現方法で大丈夫だと思いますよ。
Avatar
koher 16-Mar-21 04:54 AM
視覚的に区別はできるでしょうけど、似ているけど異なる二つのものが共存する複雑性の問題という意味でです。
Avatar
Kishikawa Katsumi 16-Mar-21 04:54 AM
明らかにわかるようにすれば大丈夫だと思います。
Avatar
omochimetaru 16-Mar-21 04:54 AM
型推論結果が let の右に出てたらわかりやすいと思う。
Avatar
Kishikawa Katsumi 16-Mar-21 04:54 AM
でもまあ初心者の人とか知らない人には難しくなる、というのはありそう。
そう考えると簡単ではないか。。。
リモートのトラブルシューティングで本当はラベル書いてないけどIDEが表示するから噛み合わない、とかあるかも。
Avatar
omochimetaru 16-Mar-21 04:56 AM
あれだなあ、
一個ずつAlt Clickするのはめんどくさいけど
常に出てると混乱の原因にはなるから
ショートカットを押してる間だけあらゆるものが浮かび上がるみたいな
UIだったら便利そうだ
見えないものが見えるようになるボタン
Avatar omochimetaru
型推論結果が let の右に出てたらわかりやすいと思う。
Avatar
koher 16-Mar-21 04:57 AM
これも、パラメトリックポリモーフィズムでネストした長大な型パラメータが出来上がりがちなSwiftだと辛いかも? ショートカットの間だけとかならありだと思う。
Avatar
omochimetaru 16-Mar-21 04:58 AM
たしかに。表示しない前提でめちゃ複雑な型が発生してる場面はありますね。
Avatar
koher 16-Mar-21 04:58 AM
ショートカット押してる間だけ表示は、かなり DX ( Experience の方の)上がりそうだなぁ。一個ずつ表示めんどすぎるので。 (edited)
Avatar koher
これも、パラメトリックポリモーフィズムでネストした長大な型パラメータが出来上がりがちなSwiftだと辛いかも? ショートカットの間だけとかならありだと思う。
Avatar
rintaro 16-Mar-21 04:59 AM
Minimap が command 押してるときだけ表示増えるという前例もあるし、良さそう (edited)
Avatar
omochimetaru 16-Mar-21 04:59 AM
Minimap が commnad 押してるときだけ表示増える
ほんとだ!!
😲 1
Avatar
tarunon 16-Mar-21 06:51 AM
IDEが頑張る世界線は、Githubにも頑張って貰う必要がある
MSがJetBrainsを買収するでFAかな
Avatar
omochimetaru 16-Mar-21 06:52 AM
そのへん LSP もそうだし、なんかその推論出すやつも規格があるらしくて
標準化してるからGitHubはビュー作るだけみたいな未来になりそう
Avatar
tarunon 16-Mar-21 06:52 AM
それはいいね
Avatar
omochimetaru 16-Mar-21 06:53 AM
👍 1
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
In the project, the student will extend SourceKit-LSP to offer functionality as described in this LSP proposal.
Avatar
tarunon 16-Mar-21 06:54 AM
それでもなお、trailing closureのラベル省略強制は失敗だったと思うなぁ
Avatar
omochimetaru 16-Mar-21 06:54 AM
Rustがやったやつを、LSPでもできるように規格拡張するプロポーザルが出ているというステータスか
Avatar
tarunon 16-Mar-21 06:54 AM
既にラベル省略するかどうかは_の有無で決定できていたのだから、それに従うで良かったはずなんだ
Avatar
omochimetaru 16-Mar-21 06:55 AM
ラベルなしクロージャが適切なデザインのAPIでは空ラベルにしておいて
ラベルありクロージャが適切ならラベルをつけておいて
呼び出し側はそれに同期すればいいよね。
Avatar
tarunon 16-Mar-21 06:55 AM
そうなんだよねぇ
Avatar
omochimetaru 16-Mar-21 06:55 AM
ほんとだよなあ
Avatar
tarunon 16-Mar-21 06:55 AM
Swiftの中でOptionalサブタイピングの次くらいにイケてないところだと思う
Avatar
omochimetaru 16-Mar-21 06:55 AM
最初見たときはめっちゃかっこいい最新の仕様だと思ったんだけど
別に省略を強制する文法である必要全く無いと思った (edited)
通常の引数でもラベルは省略できないところもSwiftが他の言語に対して大きな特徴なのに
Trailing Closureだけそのへんと一貫性がない
Avatar tarunon
Swiftの中でOptionalサブタイピングの次くらいにイケてないところだと思う
Avatar
Iceman 16-Mar-21 07:03 AM
これってどうイケてないと感じるやつですか?
Avatar
tarunon 16-Mar-21 07:06 AM
Optionalの話かな
Avatar
Iceman 16-Mar-21 07:09 AM
Optionalとラップされた型にサブタイピング関係があることでどういうときに困るんでしたっけ?
Avatar
omochimetaru 16-Mar-21 07:11 AM
なんか細かい闇がたくさんあったからまとめが欲しくなってきたな。
Avatar
tarunon 16-Mar-21 07:15 AM
根本的にはOptionalがtagged unionであるということと、T?とTのサブタイピングを認めてかつTとUがサブタイピング関係があるときにT?とU?のサブタイピングも認める、ということをしちゃうと
型理論に優先順位のルールを加えなきゃいけなくなるが、人間の認知はここまで追い付かないので
文脈によってサブタイピングがあって欲しい場合とサブタイピングを認めたくない場合が混在してしまい
人間はそれをバグと認知してしまう
仕事終わったら詳しく書くか
Avatar tarunon
仕事終わったら詳しく書くか
Avatar
Avatar
rintaro 31-Mar-21 10:59 PM
@swift-4.0.3
var foo : () -> Int foo = { foo() }
Avatar
swift40 BOT 31-Mar-21 10:59 PM
exit status: 1 with stderr:
<stdin>:2:7: error: variable 'foo' captured by a closure before being initialized foo = { foo() } ^ <stdin>:1:5: note: variable defined here var foo : () -> Int ^
Avatar
norio_nomura 12-Apr-21 11:29 PM
bot全滅中…
Avatar
norio_nomura 13-Apr-21 02:08 AM
bot復帰
DiscordがHTTPレスポンスのヘッダに
Set-Cookie: … set-cookie: …
を入れる様になり、使ってたライブラリ内で
let headers = [String: Any](uniqueKeysWithValues: response.allHeaderFields.map { (($0.key as! String).lowercased(), $0.value) })
としてcase insensitive uniqueであることを期待してた箇所でランタイムエラーになってた。
(edited)
👀 1
Avatar
koher 13-Apr-21 02:44 AM
なるほど。やっぱりサーバーと連携する(アプリの外部で仕様が変わり得る)箇所で ! 使うのは危険ですね。
Avatar
norio_nomura 13-Apr-21 03:08 AM
問題だったのは!の利用ではなく、init(uniqueKeysWithValues:)APIへ外部データがcase insensitive uniqueだと無邪気に信じて単純な変換のみで渡したことですね。
Avatar
koher 13-Apr-21 03:10 AM
ああ、すいません、わかっていたはずなのですが、 unique でない → Logic Failure → ! みたいなステップで思考がバグってました。
👍 1
uniqueKeysWithValues に渡すものがおかしいのは Logic Failure でいいと思うんですが、ユニーク化のときにユニークでない場合に Recoverable なエラーハンドリングができる簡単な方法があるといいですよね。 uniqueKeysWithValues は割と踏みがちな気がするので・・・。
guard let uniqueHeaderFields = response.allHeaderFields .map { (($0.key as! String).lowercased(), $0.value) } .unique(\.0) else { ... }
とか?
Avatar
tarunon 13-Apr-21 03:16 AM
もっとシンプルに同じ値が積まれてることを期待しちゃって
uniqueじゃ無い方を使えば良いと思いました
この場合は特に
Avatar
norio_nomura 13-Apr-21 03:17 AM
ああ、DarwinだとallHeaderFieldsがcase insensitiveなのか。
Avatar
koher 13-Apr-21 03:18 AM
uniqueじゃ無い方を使えば良いと思いました
これは Dictionary.init の話ですか?
Avatar
tarunon 13-Apr-21 03:18 AM
そうです
Avatar
koher 13-Apr-21 03:18 AM
そんな init ありましたっけ?
Avatar
tarunon 13-Apr-21 03:19 AM
Dictionary.init(_:uniquingKeysWith:) (edited)
Avatar
koher 13-Apr-21 03:19 AM
こっちか
おおお、これ知りませんでした。
これいいですね。合成もできるしエラーにもできる。
rethrows がめっちゃ活きてますね。
Avatar
norio_nomura 13-Apr-21 04:25 AM
Darwinでの挙動を調べてみると、複数のSet-Cookie[String]としてallHeaderFieldsに入るみたい。
なので、ちゃんとやるとこんな感じになる。 @swift-5.0.3
import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif guard let url = URL(string: "https://discordapp.com/api/v7/gateway/bot") else { exit(1) } let task = URLSession.shared.dataTask(with: url) { dataOrNil, responseOrNil, errorOrNil in guard let response = responseOrNil as? HTTPURLResponse else { exit(1) } let allHeaderFields = response.allHeaderFields.map { (key, value) in ((key as! String).lowercased(), value) } let headers = [String: Any](allHeaderFields, uniquingKeysWith: { (lhs, rhs) in switch (lhs, rhs) { case (let lhs as [String], let rhs as [String]): return lhs + rhs case (let lhs as [String], let rhs as String): return lhs + [rhs] case (let lhs as String, let rhs as [String]): return [lhs] + rhs case (let lhs as String, let rhs as String): return [lhs, rhs] default: return rhs } }) dump(headers) exit(0) } task.resume() dispatchMain()
(edited)
Avatar
swift50 BOT 13-Apr-21 04:26 AM
▿ 16 key/value pairs ▿ (2 elements) - key: "date" - value: "Tue, 13 Apr 2021 04:26:24 GMT" ▿ (2 elements) - key: "strict-transport-security" - value: "max-age=31536000; includeSubDomains" ▿ (2 elements) - key: "cf-ray" - value: "63f1ef9dbf553806-IAD" ▿ (2 elements) - key: "connection" - value: "keep-alive" ▿ (2 elements) - key: "cf-request-id" - value: "096b1416900000380660129000000001" ▿ (2 elements) - key: "cf-cache-status" - value: "DYNAMIC" ▿ (2 elements) - key: "via" - value: "1.1 google" ▿ (2 elements) - key: "content-length" - value: "43" ▿ (2 elements) - key: "expect-ct" - value: "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ▿ (2 elements) - key: "report-to" - value: "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report?s=6nGtl8vxSfMGS4%2Fg8PcS6skF%2FlvqoTCQES4uLM5cC146gNRLzD%2FY8X%2BPide4V6MCz57kfNUXBY084%2BCGO3VO91oIQiMHHDyZNq6LzNs4kw%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}" ▿ (2 elements) - key: "set-cookie" ▿ value: 2 elements - "__cfduid=d2062717f605ce464e7f88d444e655ede1618287984; expires=Thu, 13-May-21 04:26:24 GMT; path=/; domain=.discordapp.com; HttpOnly; SameSite=Lax" - "__dcfduid=8854356cde9c452195623d3534a3e91a; Expires=Thu, 13-May-2021 04:26:24 GMT; Max-Age=2592000; Secure; HttpOnly; Path=/" ▿ (2 elements) - key: "nel" - value: "{\"max_age\":604800,\"report_to\":\"cf-nel\"}" ▿ (2 elements) - key: "alt-svc" - value: "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400" ▿ (2 elements) - key: "x-envoy-upstream-service-time" - value: "5" ▿ (2 elements) - key: "server" - value: "cloudflare" ▿ (2 elements) - key: "content-type" - value: "application/json"
Avatar
norio_nomura 13-Apr-21 04:33 AM
あとDarwinだとkeyの大文字小文字は最初に現れたものを維持するみたい。
📝 1
Avatar
Iceman 16-Apr-21 02:07 AM
@swift-5.3.3
struct Box<T> {} @_functionBuilder struct MyBuilder { static func buildBlock(_ component: Box<Never>) -> Box<Never> { component } } func take(_ c: () -> Box<Never>) {} func takeBuild(@MyBuilder _ c: () -> Box<Never>) {} take { Box() } takeBuild { Box() }
Avatar
swift53 BOT 16-Apr-21 02:07 AM
exit status: 1 with stderr:
<stdin>:19:5: error: cannot convert value of type 'Box<_>' to expected argument type 'Box<Never>' Box() ^ <stdin>:1:12: note: arguments to generic parameter 'T' ('_' and 'Never') are expected to be equal struct Box<T> {} ^ <stdin>:19:5: error: generic parameter 'T' could not be inferred Box() ^ <stdin>:1:12: note: 'T' declared as parameter to type 'Box' struct Box<T> {} ^ <stdin>:19:5: note: explicitly specify the generic arguments to fix this issue Box() ^ <Any>
Avatar
rintaro 16-Apr-21 03:44 AM
@swift-5.3.3
struct Box<T> {} @_functionBuilder struct MyBuilder { static func buildExpression(_ expression: Box<Never>) -> Box<Never> { expression } static func buildBlock(_ component: Box<Never>) -> Box<Never> { component } } func take(_ c: () -> Box<Never>) {} func takeBuild(@MyBuilder _ c: () -> Box<Never>) {} func test() { take { Box() } takeBuild { Box() } }
Avatar
swift53 BOT 16-Apr-21 03:44 AM
no output
Avatar Iceman
@swift-5.3.3
struct Box<T> {} @_functionBuilder struct MyBuilder { static func buildBlock(_ component: Box<Never>) -> Box<Never> { component } } func take(_ c: () -> Box<Never>) {} func takeBuild(@MyBuilder _ c: () -> Box<Never>) {} take { Box() } takeBuild { Box() }
Avatar
rintaro 16-Apr-21 03:45 AM
コンテキストで推論させたいときは、buildExpression(_:) が必要ですね。
Avatar
Iceman 16-Apr-21 03:46 AM
おおできました!ありがとうございます
Avatar
rintaro 16-Apr-21 03:47 AM
https://github.com/apple/swift-evolution/blob/main/proposals/0289-result-builders.md#result-building-methods
buildExpression(_ expression: Expression) -> Component is used to lift the results of expression-statements into the Component internal currency type. It is optional, but when provided it allows a result builder to distinguish Expression types from Component types or to provide contextual type information for statement-expressions.
Avatar
tarunon 16-Apr-21 03:48 AM
expression入れたらflatMapの例も通るようになりました
Avatar
Iceman 16-Apr-21 03:49 AM
他にも見たこと無いのあって面白い
Avatar
norio_nomura 21-Apr-21 09:57 AM
今までボットを動かすHeroku用のアカウントを<メイン>+swift5.x@gmail.com的なGmailのエリアスアドレスでサインアップしてたけど、Swift 5.5ボット用に新規アカウントをサインアップしようとしたら、メールアドレスで弾かれた… なのでSwift 5.5ボット立ち上げは少し遅れそう。
📧 2
Avatar
koher 21-Apr-21 08:38 PM
5.5 の Release Process 、ブログじゃなくて↓こんなところにあったんですね。これはやっぱ 6 は今年は来ないのかな・・・。 https://forums.swift.org/t/swift-5-5-release-process/45644
This post describes the release process, and estimated schedule for Swift 5.5. Snapshots of Swift 5.5 Downloadable snapshots of the Swift 5.5 release branch will be posted regularly as part of continuous integration testing. As support is available, snapshot downloads will be added for newly supported platforms. Once Swift 5.5 is released, the...
Avatar
Iceman 30-Apr-21 07:11 AM
@swift-5.3.3
(["value": Int?(1)] as [String: String?])
Avatar
swift53 BOT 30-Apr-21 07:11 AM
exit status: 134 with stderr:
<stdin>:1:21: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead (["value": Int?(1)] as [String: String?]) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ <stdin>:1:21: warning: expression of type '[String : String?]' is unused (["value": Int?(1)] as [String: String?]) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %40, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.I
Avatar
Iceman 30-Apr-21 07:13 AM
@swift-5.3.3
_ = ["value": Int?(1)] as [String: String?]
Avatar
swift53 BOT 30-Apr-21 07:13 AM
exit status: 134 with stderr:
<stdin>:1:24: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead _ = ["value": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %40, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.Int1, -1 // user: %15 %13 = metatype $@thin String.Type // user: %15 // function_ref String.init(_builtinStringLiteral:utf8Cod
Avatar
Iceman 30-Apr-21 07:14 AM
@swift-5.2.5 @swift-5.4.3 @swift-nightly
_ = ["value": Int?(1)] as [String: String?]
Avatar
swiftNightly BOT 30-Apr-21 07:14 AM
exit status: 134 with stderr:
<stdin>:1:24: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead _ = ["value": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %38, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.Int1, -1 // user: %15 %13 = metatype $@thin String.Type // user: %15 // function_ref String.init(_builtinStringLiteral:utf8Cod
Avatar
swift52 BOT 30-Apr-21 07:14 AM
exit status: 1 with stderr:
<stdin>:1:15: error: cannot convert value of type 'Optional<Int>' to expected dictionary value type 'String' _ = ["value": Int?(1)] as [String: String?] ^
Avatar
swift54 BOT 30-Apr-21 07:14 AM
exit status: 134 with stderr:
<stdin>:1:24: warning: coercion from '[String : Int?]' to '[String : String?]' may fail; use 'as?' or 'as!' instead _ = ["value": Int?(1)] as [String: String?] ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ SIL verification failed: branch argument types do not match arguments for dest bb: std::equal(BI->getArgs().begin(), BI->getArgs().end(), BI->getDestBB()->args_begin(), [&](SILValue branchArg, SILArgument *bbArg) { return verifyBranchArgs(branchArg, bbArg); }) Verifying instruction: %31 = enum $Optional<Int>, #Optional.some!enumelt, %30 : $Int // user: %32 -> br bb3(%31 : $Optional<Int>) // id: %32 In function: // main sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Word, 1 // user: %4 // function_ref _allocateUninitializedArray<A>(_:) %3 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %4 %4 = apply %3<(String, Optional<String>)>(%2) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %5 (%5, %6) = destructure_tuple %4 : $(Array<(String, Optional<String>)>, Builtin.RawPointer) // users: %38, %7 %7 = pointer_to_address %6 : $Builtin.RawPointer to [strict] $*(String, Optional<String>) // users: %9, %8 %8 = tuple_element_addr %7 : $*(String, Optional<String>), 0 // user: %16 %9 = tuple_element_addr %7 : $*(String, Optional<String>), 1 // user: %36 %10 = string_literal utf8 "value" // user: %15 %11 = integer_literal $Builtin.Word, 5 // user: %15 %12 = integer_literal $Builtin.Int1, -1 // user: %15 %13 = metatype $@thin String.Type // user: %15 // function_ref String.init(_builtinStringLiteral:utf8Cod
Avatar
Iceman 30-Apr-21 07:14 AM
なんか壊れてるな
Avatar
tarunon 30-Apr-21 07:16 AM
キャスト周りをResultBuilderに噛ませると壊れるの観測してたけど、関係なく壊れてるのね
Avatar
omochimetaru 30-Apr-21 07:25 AM
秘孔だ
Avatar
Kishikawa Katsumi 30-Apr-21 07:52 AM
こんなバグがまだ見つかるんですねえ😲
Avatar
rintaro 12-May-21 10:05 PM
@swift-5.3.3 @swift-5.4.3
class MyCls {} let obj: MyCls = { obj }() print(obj)
Avatar
swift53 BOT 12-May-21 10:05 PM
exit status: 1 with stderr:
<stdin>:2:20: error: variable used within its own initial value let obj: MyCls = { obj }() ^
Avatar
swift54 BOT 12-May-21 10:05 PM
exit status: 11 with stderr:
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-name main -lLibraries 1. Swift version 5.4 (swift-5.4-RELEASE) 2. While running us
Avatar
omochimetaru 13-May-21 01:26 AM
あらま
謎のデグレ
普通にテストケースありそうなシンプルなパターンなのに。
Avatar
omochimetaru 05-Jun-21 12:43 AM
@swift-5.4.3 @swift-nightly
enum E: Codable { case a(Int) }
Avatar
swift54 BOT 05-Jun-21 12:43 AM
exit status: 1 with stderr:
<stdin>:1:6: error: type 'E' does not conform to protocol 'Decodable' enum E: Codable { ^ <stdin>:1:6: error: type 'E' does not conform to protocol 'Encodable' enum E: Codable { ^ Swift.Decodable:2:5: note: protocol requires initializer 'init(from:)' with type '(from: Decoder)' init(from decoder: Decoder) throws ^ Swift.Encodable:2:10: note: protocol requires function 'encode(to:)' with type '(Encoder) throws -> ()' func encode(to encoder: Encoder) throws ^
Avatar
swiftNightly BOT 05-Jun-21 12:43 AM
no output
Avatar
omochimetaru 05-Jun-21 12:45 AM
5.5 development snapshot 使ってもSE-0295使えなかったんだけど
release/5.5 ブランチにこれがマージ済みかどうかってGitHubでどうやって調べればいいんだろう
SE-295 has been accepted, so we don't need to hide the feature behind a flag anymore.
Avatar
rintaro 05-Jun-21 12:51 AM
両方 release/5.5 に入ってそう
Avatar
omochimetaru 05-Jun-21 12:51 AM
あれー?
これでいいんでしたっけ
Avatar
rintaro 05-Jun-21 12:52 AM
https://github.com/apple/swift/commit/c03c3b266d411481d81a86d1591aa96ab1bfbcd7 のタグリストに、swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a あるのでいけると思うんですが・・・
[Frontend] Remove enable-experimental-enum-codable-derivation flag
Avatar
omochimetaru 05-Jun-21 12:53 AM
あ、いけた、わかった
xcodeが裏で立ててる?lldbが切り替わってなくて壊れたっぽかった
ビルドはできるけどエディタでエラーが出てて実行するとlldbなんちゃらかんちゃらって謎のエラーが出てた
👍 1
失礼しました
Avatar
rintaro 05-Jun-21 12:56 AM
release/5.5 ブランチにこれがマージ済みかどうかってGitHubでどうやって調べればいいんだろう
github じゃないけど
git branch -a --contains c03c3b266d411481d81a86d1591aa96ab1bfbcd7 | grep release/5.5
とかですかね
Avatar
omochimetaru 05-Jun-21 12:57 AM
gitでやるのが早いか。固定回線がいまなくて渋ってました。
--contains というのがあるんすね。
ビルドはできるけど実行できないや Xcode12.5とswift5.5の何かが噛み合わないっぽいな
[omochi@omochi-iMacPro Sandbox]$ swift --version Apple Swift version 5.5-dev (LLVM 32757f073852da0, Swift 976d23d3f72d24b) Target: x86_64-apple-macosx11.0 [omochi@omochi-iMacPro Sandbox]$ swift main.swift Killed: 9 [omochi@omochi-iMacPro Sandbox]$ swift dyld: Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3 Referenced from: /Library/Developer/Toolchains/swift-5.5-DEVELOPMENT-SNAPSHOT-2021-06-02-a.xctoolchain/System/Library/PrivateFrameworks/LLDB.framework/Versions/A/LLDB Reason: image not found Abort trap: 6
同梱されてるLLDBがPython3.8に依存してる?
Avatar
omochimetaru 05-Jun-21 01:28 AM
うーん公式のPython3.8を入れてみたけど
/Library/Frameworks/Python.framework で、 Python3.framework じゃない。
Avatar
omochimetaru 05-Jun-21 01:42 AM
Load command 27 cmd LC_RPATH cmdsize 80 path /Applications/Xcode.app/Contents/Developer/Library/Frameworks/ (offset 12)
[omochi@omochi-iMacPro Library]$ ls /Applications/Xcode12.5.app/Contents/Developer/Library/Frameworks | grep Python3 Python3.framework
なるほど。
Avatar
omochimetaru 05-Jun-21 01:50 AM
Xcode.app -> Xcode12.5.app 置いたけどまだ駄目だ
[omochi@omochi-iMacPro Sandbox]$ swift error: failed to launch REPL process: process exited with status -1 (attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))
Xcodeからは実行できるようになった・・・
Avatar
omochimetaru 05-Jun-21 04:33 PM
@swift-nightly
import Foundation enum E: Codable { case a(Int?) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let json = try encoder.encode(E.a(nil)) print(String(data: json, encoding: .utf8)!)
Avatar
swiftNightly BOT 05-Jun-21 04:33 PM
{ "a" : { } }
Avatar
omochimetaru 05-Jun-21 04:33 PM
あーやっぱそうなんか。 (edited)
Avatar
omochimetaru 05-Jun-21 04:48 PM
@swift-nightly
import Foundation enum E: Codable { case a(Int??) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let json = try encoder.encode(E.a(.some(.none))) print(String(data: json, encoding: .utf8)!)
Avatar
swiftNightly BOT 05-Jun-21 04:48 PM
{ "a" : { "_0" : null } }
Avatar
omochimetaru 05-Jun-21 04:48 PM
うぇえぇ
Avatar
Kishikawa Katsumi 05-Jun-21 04:48 PM
意図した挙動なんだろうか
Avatar
omochimetaru 05-Jun-21 04:49 PM
一応こうなってると、 .some(.some(1)) .some(.none) .none のどれもが異なるJSONになるので、
デコードできていい・・・? ほんとか?デコード側どうなんだろう
Avatar
Kishikawa Katsumi 05-Jun-21 04:49 PM
3重以上になったらどうなるのかなあ。
Avatar
omochimetaru 05-Jun-21 04:49 PM
たしかに!w
@swift-nightly
import Foundation enum E: Codable { case a(Int???) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let value: [E] = [ .a(.none), .a(.some(.none)), .a(.some(.some(.none))), .a(.some(.some(.some(1)))) ] let json = try encoder.encode(value) print(String(data: json, encoding: .utf8)!)
(edited)
Avatar
swiftNightly BOT 05-Jun-21 04:50 PM
exit status: 1 with stderr:
<stdin>:10:6: error: enum case 'a' cannot be used as an instance member .a(.none) ~^~~~~~~~ E <stdin>:11:6: error: enum case 'a' cannot be used as an instance member .a(.some(.none)) ~~~~~^~~~~~~~~~~~~~~ E <stdin>:12:6: error: enum case 'a' cannot be used as an instance member .a(.some(.some(.none))) ~~~~~^~~~~~~~~~~~~~~~~~~~~~ E
Avatar
omochimetaru 05-Jun-21 04:51 PM
@swift-nightly
import Foundation enum E: Codable { case a(Int???) } let encoder = JSONEncoder() encoder.outputFormatting = .prettyPrinted let value: [E] = [ .a(.none), .a(.some(.none)), .a(.some(.some(.none))), .a(.some(.some(.some(1)))) ] let json = try encoder.encode(value) print(String(data: json, encoding: .utf8)!)
Avatar
swiftNightly BOT 05-Jun-21 04:51 PM
[ { "a" : { } }, { "a" : { "_0" : null } }, { "a" : { "_0" : null } }, { "a" : { "_0" : 1 } } ]
Avatar
Kishikawa Katsumi 05-Jun-21 04:52 PM
元の型が2重または3重オプショナルの場合エンコード結果から元の型はわからないけどそれは問題ないんですよね?
Avatar
omochimetaru 05-Jun-21 04:52 PM
型のほうは case名のキーの a で残ってるんでいいのです
Avatar
Kishikawa Katsumi 05-Jun-21 04:53 PM
まあそうか。オプショナルは元々のEnum含まない使用でも広く受けることできますしね。
Avatar
omochimetaru 05-Jun-21 04:53 PM
一番外側の none は キーレス、一番内側のsomeは値、その中間レベルの .some の中の .none は全部 null につぶれてしまうようだ。
中間の null は正しくデコードできるのか・・・?
@swift-nightly
import Foundation enum E: Codable { case a(Int???) } let decoder = JSONDecoder() let json = """ [ { "a" : { } }, { "a" : { "_0" : null } }, { "a" : { "_0" : null } }, { "a" : { "_0" : 1 } } ] """.data(using: .utf8)! let value = try decoder.decode([E].self, from: json) dump(value)
Avatar
swiftNightly BOT 05-Jun-21 04:55 PM
▿ 4 elements ▿ main.E.a - a: nil ▿ main.E.a - a: nil ▿ main.E.a - a: nil ▿ main.E.a ▿ a: Optional(Optional(Optional(1))) ▿ some: Optional(Optional(1)) ▿ some: Optional(1) - some: 1
Avatar
omochimetaru 05-Jun-21 04:55 PM
駄目だな。デコード側はキーレスとキー有りのnullの区別もできない。
エンコード側は3種類の出力があるけどデコードは2種類(最も外側noneと最も内側some)しか扱えないと。
Avatar
Kishikawa Katsumi 05-Jun-21 04:56 PM
意図した挙動じゃない気がしますねえ。
エンコードのほう。
キーがあるnilで良さそうですけどキーがないほうが自然ですか?
私の印象はパッと見ての印象だから違うかもしれない。
Avatar
omochimetaru 05-Jun-21 04:58 PM
codableってそうなんですよね、キーも出さない
SE-0295のenumのassoc valueのoptionalの扱いについては文書で触れてないけど、 (edited)
Avatar
Kishikawa Katsumi 05-Jun-21 05:00 PM
なるほど。もともとのCodableはnilのときキーごと消すんでしたか。
まあそうすると "_0" : null はnullという値があるっていう表現になるから合ってるのか。
まあJSONの仕様を超えてるし難しいところだ。
Avatar
omochimetaru 05-Jun-21 05:02 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
うーん、Codable自動実装のプロポーザルどれだ?
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
最初からあったのか。
うーん、SE-0166に明確な言及は無い気がする・・・w
Avatar
omochimetaru 05-Jun-21 05:32 PM
できた。ちょっと実装がむずかった。
Avatar
niw 09-Jun-21 01:09 AM
@swift-nightly
struct A { let i: Int } struct B { let a: A? = nil } let _: [Any] = [B()].compactMap(\.a?.i)
Avatar
swiftNightly BOT 09-Jun-21 01:09 AM
exit status: 1 with stderr:
<stdin>:2:1: error: extraneous '}' at top level } ^ <stdin>:4:10: error: cannot find type 'A' in scope let a: A? = nil ^
Avatar
niw 09-Jun-21 01:10 AM
@swift-nightly
struct A { let i: Int } struct B { let a: A? = nil } let _: [Any] = [B()].compactMap(\.a?.i)
Avatar
swiftNightly BOT 09-Jun-21 01:10 AM
exit status: 134 with stderr:
swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-16_04/swift/lib/Sema/CSApply.cpp:4968: swift::Expr *(anonymous namespace)::ExprRewriter::visitKeyPathExpr(swift::KeyPathExpr *): Assertion `leafTy->getOptionalObjectType()->isEqual( componentTy->getWithoutSpecifierType())' failed. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -Xllvm -enable-swifttailcc-musttail-check -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/
Avatar
niw 09-Jun-21 01:10 AM
ふむ
Avatar
Ensan 09-Jun-21 02:57 AM
@swift-nightly
@propertyWrapper struct Wrapper<T> { init(wrappedValue: T) { self.wrappedValue = wrappedValue } init(projectedValue: Self) { self.wrappedValue = projectedValue.wrappedValue } var wrappedValue: T var projectedValue: Self { return self } } let useWrapper: (Wrapper<Int>) -> Void = { $$0 in print($$0) print(_$0) }
Avatar
swiftNightly BOT 09-Jun-21 02:57 AM
no output
Avatar
Ensan 09-Jun-21 02:58 AM
これがコンパイル通るのって正しいんでしょうか 変数名に$が使えるのか (edited)
Avatar
kateinoigakukun 13-Jun-21 11:00 AM
@swift-nightly
protocol P1 {} protocol P2 { associatedtype X: P1 = Int }
Avatar
swiftNightly BOT 13-Jun-21 11:00 AM
no output
Avatar
kateinoigakukun 13-Jun-21 11:01 AM
IntはP1にconformしないのでXのデフォルト値として常に成り立たないんだけど、デフォルト値の宣言の時点ではエラーにならない
例えばP1がpublicかつ外部モジュールで extension Int: P1 {} された場合、 X: P1 が成り立つケースはあるがinternalな場合はエラーでいい気がする
Avatar
omochimetaru 16-Jun-21 05:23 AM
@swift-5.3.3 @swift-5.4.3 @swift-nightly
func f() { var a: Int? = 1 guard let a = a else { return } _ = a + 1 }
Avatar
swift54 BOT 16-Jun-21 05:23 AM
stderr:
<stdin>:2:7: warning: variable 'a' was never mutated; consider changing to 'let' constant var a: Int? = 1 ~~~ ^ let
Avatar
swift53 BOT 16-Jun-21 05:23 AM
exit status: 1 with stderr:
<stdin>:3:13: error: definition conflicts with previous value guard let a = a else { return } ^ <stdin>:2:7: note: previous definition of 'a' is here var a: Int? = 1 ^ <stdin>:4:7: error: value of optional type 'Int?' must be unwrapped to a value of type 'Int' _ = a + 1 ^ <stdin>:4:7: note: coalesce using '??' to provide a default when the optional value contains 'nil' _ = a + 1 ^ ?? <#default value#> <stdin>:4:7: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' _ = a + 1 ^ !
Avatar
swiftNightly BOT 16-Jun-21 05:23 AM
stderr:
<stdin>:2:7: warning: variable 'a' was never mutated; consider changing to 'let' constant var a: Int? = 1 ~~~ ^ let
Avatar
omochimetaru 16-Jun-21 05:24 AM
@swift-5.3.3 @swift-5.4.3 @swift-nightly
func f() { var a = 1 var a = 1 }
Avatar
swift54 BOT 16-Jun-21 05:24 AM
exit status: 1 with stderr:
<stdin>:3:7: error: invalid redeclaration of 'a' var a = 1 ^ <stdin>:2:7: note: 'a' previously declared here var a = 1 ^
Avatar
swift53 BOT 16-Jun-21 05:24 AM
exit status: 1 with stderr:
<stdin>:3:7: error: definition conflicts with previous value var a = 1 ^ <stdin>:2:7: note: previous definition of 'a' is here var a = 1 ^ <stdin>:2:7: warning: initialization of variable 'a' was never used; consider replacing with assignment to '_' or removing it var a = 1 ~~~~^ _ <stdin>:3:7: warning: initialization of variable 'a' was never used; consider replacing with assignment to '_' or removing it var a = 1 ~~~~^ _
Avatar
swiftNightly BOT 16-Jun-21 05:24 AM
exit status: 1 with stderr:
<stdin>:3:7: error: invalid redeclaration of 'a' var a = 1 ^ <stdin>:2:7: note: 'a' previously declared here var a = 1 ^
Avatar
omochimetaru 16-Jun-21 05:24 AM
Swift5.4からローカル変数をguardでshadowできるの知らなかった。
Avatar
koher 25-Jun-21 08:05 AM
@swift-nightly
import Foundation enum Foo: String, Codable { case bar = "bar" } let data = try! JSONEncoder().encode(Foo.bar) let string = String(data: data, encoding: .utf8)! print(string)
Avatar
swiftNightly BOT 25-Jun-21 08:05 AM
"bar"
Avatar
koher 25-Jun-21 08:06 AM
@swift-nightly
import Foundation enum Foo: Codable { case bar } let data = try! JSONEncoder().encode(Foo.bar) let string = String(data: data, encoding: .utf8)! print(string)
Avatar
swiftNightly BOT 25-Jun-21 08:06 AM
{"bar":{}}
Avatar
omochimetaru 25-Jun-21 09:12 AM
うむ (edited)
Avatar
rintaro 30-Jun-21 04:57 PM
@swift-5.0.3 @swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3
func test(_ callback: () -> Void) { let x = callback x() }
https://forums.swift.org/t/an-odd-error-escaping-closure-captures-mutating-self/50118/10
(edited)
Avatar
swift54 BOT 30-Jun-21 04:57 PM
no output
Avatar
swift52 BOT 30-Jun-21 04:57 PM
no output
Avatar
swift53 BOT 30-Jun-21 04:57 PM
no output
Avatar
swift50 BOT 30-Jun-21 04:57 PM
exit status: 1 with stderr:
<stdin>:2:13: error: non-escaping parameter 'callback' may only be called let x = callback ^ <stdin>:1:11: note: parameter 'callback' is implicitly non-escaping func test(_ callback: () -> Void) { ^ @escaping
Avatar
swift51 BOT 30-Jun-21 04:58 PM
no output
Avatar
Iceman 02-Jul-21 06:32 AM
@swift-5.4.3
import CoreFoundation print(CFSwapInt16HostToBig)
Avatar
swift54 BOT 02-Jul-21 06:32 AM
(Function)
Avatar
Iceman 02-Jul-21 06:32 AM
@swift-5.4.3
import Foundation print(CFSwapInt16HostToBig)
Avatar
swift54 BOT 02-Jul-21 06:32 AM
exit status: 1 with stderr:
<stdin>:2:7: error: cannot find 'CFSwapInt16HostToBig' in scope print(CFSwapInt16HostToBig) ^~~~~~~~~~~~~~~~~~~~
Avatar
d_date 02-Jul-21 08:00 AM
@swift-nightly
import Foundation enum A: Hashable { case unix(path: Swift.String) @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) case url(_: URL) @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) case srv(_: Swift.String) }
Avatar
swiftNightly BOT 02-Jul-21 08:00 AM
no output
Avatar
Ensan 07-Jul-21 02:51 PM
@swift-nightly
struct Test { func left() async -> String { "l" } func right() async -> String { "r" } func test() async { async let (l, r) = (left(), right()) print(await l) print(await r) } }
Avatar
swiftNightly BOT 07-Jul-21 02:51 PM
exit status: 1 with stderr:
<stdin>:6:9: error: 'async' modifier is only valid when experimental concurrency is enabled async let (l, r) = (left(), right()) ^ <stdin>:8:15: warning: no 'async' operations occur within 'await' expression print(await l) ^ <stdin>:9:15: warning: no 'async' operations occur within 'await' expression print(await r) ^ <stdin>:6:28: error: expression is 'async' but is not marked with 'await' async let (l, r) = (left(), right()) ^~~~~~~~~~~~~~~~~ await <stdin>:6:29: note: call is 'async' async let (l, r) = (left(), right()) ^ <stdin>:6:37: note: call is 'async' async let (l, r) = (left(), right()) ^
Avatar
d_date 08-Jul-21 03:24 PM
@swift-nightly
import Foundation struct LoggedInState {} struct LoggedOutState {} let date1 = Date() let date2 = Date() enum Permission: Equatable { case freeDuring(Range<Date>) case free case subscriberOnly } print(enumTag(Permission.freeDuring(date1 ..< date2))) print(enumTag(Permission.free)) print(enumTag(Permission.subscriberOnly)) private func enumTag<Case>(_ `case`: Case) -> UInt32? { let metadataPtr = unsafeBitCast( type(of: `case`), to: UnsafeRawPointer.self ) let kind = metadataPtr.load(as: Int.self) let isEnumOrOptional = kind == 0x201 || kind == 0x202 guard isEnumOrOptional else { return nil } let vwtPtr = (metadataPtr - MemoryLayout<UnsafeRawPointer>.size) .load(as: UnsafeRawPointer.self) let vwt = vwtPtr.load(as: EnumValueWitnessTable.self) return withUnsafePointer(to: `case`) { vwt.getEnumTag($0, metadataPtr) } } private struct EnumValueWitnessTable { let f1, f2, f3, f4, f5, f6, f7, f8: UnsafeRawPointer let f9, f10: Int let f11, f12: UInt32 let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32 let f13, f14: UnsafeRawPointer }
(edited)
Avatar
swiftNightly BOT 08-Jul-21 03:24 PM
stderr:
<stdin>:14:1: warning: result of call to 'enumTag' is unused enumTag(Permission.freeDuring(date1 ..< date2)) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:15:1: warning: result of call to 'enumTag' is unused enumTag(Permission.free) ^ ~~~~~~~~~~~~~~~~~ <stdin>:16:1: warning: result of call to 'enumTag' is unused enumTag(Permission.subscriberOnly) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Avatar
d_date 08-Jul-21 03:25 PM
@swift-nightly
import Foundation struct LoggedInState {} struct LoggedOutState {} let date1 = Date() let date2 = Date() enum Permission: Equatable { case freeDuring(Range<Date>) case free case subscriberOnly } print(enumTag(Permission.freeDuring(date1 ..< date2))) print(enumTag(Permission.free)) print(enumTag(Permission.subscriberOnly)) private func enumTag<Case>(_ `case`: Case) -> UInt32? { let metadataPtr = unsafeBitCast( type(of: `case`), to: UnsafeRawPointer.self ) let kind = metadataPtr.load(as: Int.self) let isEnumOrOptional = kind == 0x201 || kind == 0x202 guard isEnumOrOptional else { return nil } let vwtPtr = (metadataPtr - MemoryLayout<UnsafeRawPointer>.size) .load(as: UnsafeRawPointer.self) let vwt = vwtPtr.load(as: EnumValueWitnessTable.self) return withUnsafePointer(to: `case`) { vwt.getEnumTag($0, metadataPtr) } } private struct EnumValueWitnessTable { let f1, f2, f3, f4, f5, f6, f7, f8: UnsafeRawPointer let f9, f10: Int let f11, f12: UInt32 let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32 let f13, f14: UnsafeRawPointer }
Avatar
swiftNightly BOT 08-Jul-21 03:25 PM
Optional(0) Optional(1) Optional(2)
stderr:
<stdin>:14:7: warning: expression implicitly coerced from 'UInt32?' to 'Any' print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:14:7: note: provide a default value to avoid this warning print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:14:7: note: force-unwrap the value to avoid this warning print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! <stdin>:14:7: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(enumTag(Permission.freeDuring(date1 ..< date2))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ as Any <stdin>:15:7: warning: expression implicitly coerced from 'UInt32?' to 'Any' print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:15:7: note: provide a default value to avoid this warning print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:15:7: note: force-unwrap the value to avoid this warning print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ ! <stdin>:15:7: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(enumTag(Permission.free)) ^~~~~~~~~~~~~~~~~~~~~~~~ as Any <stdin>:16:7: warning: expression implicitly coerced from 'UInt32?' to 'Any' print(enumTag(Permission.subscriberOnly)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:16:7: note: provide a default value to avoid this warning print(enumTag(Permission.subscriberOnly)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#defau
Avatar
d_date 08-Jul-21 03:26 PM
@swift-nightly
import Foundation struct LoggedInState {} struct LoggedOutState {} let date1 = Date() let date2 = Date() enum Permission: Equatable { case freeDuring(Range<Date>) case free case subscriberOnly } print(enumTag(Permission.freeDuring(date1 ..< date2))!) print(enumTag(Permission.free)!) print(enumTag(Permission.subscriberOnly)!) private func enumTag<Case>(_ `case`: Case) -> UInt32? { let metadataPtr = unsafeBitCast( type(of: `case`), to: UnsafeRawPointer.self ) let kind = metadataPtr.load(as: Int.self) let isEnumOrOptional = kind == 0x201 || kind == 0x202 guard isEnumOrOptional else { return nil } let vwtPtr = (metadataPtr - MemoryLayout<UnsafeRawPointer>.size) .load(as: UnsafeRawPointer.self) let vwt = vwtPtr.load(as: EnumValueWitnessTable.self) return withUnsafePointer(to: `case`) { vwt.getEnumTag($0, metadataPtr) } } private struct EnumValueWitnessTable { let f1, f2, f3, f4, f5, f6, f7, f8: UnsafeRawPointer let f9, f10: Int let f11, f12: UInt32 let getEnumTag: @convention(c) (UnsafeRawPointer, UnsafeRawPointer) -> UInt32 let f13, f14: UnsafeRawPointer }
Avatar
swiftNightly BOT 08-Jul-21 03:26 PM
0 1 2
Avatar
t.ae 09-Jul-21 01:46 AM
@swift-5.4.3
@propertyWrapper struct Wrapper { var wrappedValue: Int? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } } class Test { @Wrapper var foo: Int? init() { self.foo = foo } }
Avatar
swift54 BOT 09-Jul-21 01:46 AM
no output
Avatar
Iceman 12-Jul-21 09:03 AM
@swift-nightly
print("スウィフト".lowercased())
Avatar
swiftNightly BOT 12-Jul-21 09:03 AM
スウィフト
Avatar
Iceman 13-Jul-21 08:11 AM
@swift-5.4.3
import Foundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000)))
(edited)
Avatar
swift54 BOT 13-Jul-21 08:11 AM
exit status: 1 with stderr:
<stdin>:1:22: error: cannot find type 'NumberFormatter' in scope let numberFormatter: NumberFormatter = { ^~~~~~~~~~~~~~~ <stdin>:8:37: error: cannot infer contextual base in reference to member 'init' print(numberFormatter.string(from: .init(value: 1000))) ~^~~~
Avatar
Iceman 13-Jul-21 08:17 AM
@swift-5.4.3
import Foundation import CoreFoundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000)))
(edited)
Avatar
swift54 BOT 13-Jul-21 08:17 AM
exit status: 1 with stderr:
<stdin>:3:22: error: cannot find type 'NumberFormatter' in scope let numberFormatter: NumberFormatter = { ^~~~~~~~~~~~~~~ <stdin>:10:37: error: cannot infer contextual base in reference to member 'init' print(numberFormatter.string(from: .init(value: 1000))) ~^~~~
Avatar
kateinoigakukun 13-Jul-21 08:41 AM
あれ、NumberFormatter無いんでしたっけ
Avatar
Iceman 13-Jul-21 08:43 AM
いや、いるらしいです。Botに何故か居ないのは謎https://swiftfiddle.com/rr4cuzgkcfe3jjxhlejmnkscna
SwiftFiddle is an online playground for creating, sharing and embedding Swift fiddles (little Swift programs that run directly in your browser).
Avatar
kateinoigakukun 13-Jul-21 08:45 AM
謎だ
Avatar
noppe 13-Jul-21 08:55 AM
NumberFormatterってFoundationじゃないですか?
The Foundation Project, providing core utilities, internationalization, and OS independence - apple/swift-corelibs-foundation
あ、よく見たら試していたなんでもないです
Avatar
kateinoigakukun 13-Jul-21 08:58 AM
そうそう、実装もあるように見えるんですけどねえ
Avatar
Kishikawa Katsumi 13-Jul-21 09:05 AM
BotとSwiftfiddleの (edited)
違いは実行の仕方だな。Swiftfiddleはswift file.swiftで実行してるけどBotは一度実行ファイルを作ってるはず。
Avatar
norio_nomura 13-Jul-21 10:24 AM
@swift-5.4.3
import Foundation import CoreFoundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000)))
Avatar
swift54 BOT 13-Jul-21 10:24 AM
Optional("1,000")
stderr:
<stdin>:11:7: warning: expression implicitly coerced from 'String?' to 'Any' print(numberFormatter.string(from: .init(value: 1000))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:11:23: note: provide a default value to avoid this warning print(numberFormatter.string(from: .init(value: 1000))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ?? <#default value#> <stdin>:11:23: note: force-unwrap the value to avoid this warning print(numberFormatter.string(from: .init(value: 1000))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! <stdin>:11:23: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(numberFormatter.string(from: .init(value: 1000))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ as Any
Avatar
kateinoigakukun 13-Jul-21 10:28 AM
あれ動いてる、何が違ったんですか?
Avatar
norio_nomura 13-Jul-21 10:29 AM
わかんない
Avatar
kateinoigakukun 13-Jul-21 10:29 AM
www
Avatar
Iceman 13-Jul-21 10:29 AM
www
Avatar
norio_nomura 13-Jul-21 10:56 AM
コピペしただけなんですけどね
Avatar Kishikawa Katsumi
違いは実行の仕方だな。Swiftfiddleはswift file.swiftで実行してるけどBotは一度実行ファイルを作ってるはず。
Avatar
norio_nomura 13-Jul-21 10:59 AM
実行ファイルは作っていません。ソースコードをswift -への標準入力として渡してます。 (edited)
Avatar
Kishikawa Katsumi 13-Jul-21 11:00 AM
あら、そうでしたか。すみません。勘違いです。 じゃあ前に違いがある話が出たのは私が作ったBotとの違いかな?
Avatar
norio_nomura 13-Jul-21 11:10 AM
swift54ボットのインスタンスも午前3:55に再起動したきり起動しっぱなし。何が違ったのか…
あー、ボットへのメンションが含まれたメッセージが編集された後、ボットからの返答を更新するのに失敗してるぽい。
@swift-5.4.3
import Foundation import CoreFoundation let numberFormatter: NumberFormatter = { let f = NumberFormatter() f.numberStyle = .decimal f.usesGroupingSeparator = true return f }() print(numberFormatter.string(from: .init(value: 1000)))
(edited)
Avatar
swift54 BOT 13-Jul-21 11:14 AM
exit status: 1 with stderr:
<stdin>:3:22: error: cannot find type 'NumberFormatter' in scope let numberFormatter: NumberFormatter = { ^~~~~~~~~~~~~~~ <stdin>:10:37: error: cannot infer contextual base in reference to member 'init' print(numberFormatter.string(from: .init(value: 1000))) ~^~~~
Avatar
norio_nomura 13-Jul-21 11:15 AM
^コンパイルエラーが出るメッセージを渡してから、それを修正することで再現した。
Avatar
kateinoigakukun 13-Jul-21 11:15 AM
なるほど
Avatar
norio_nomura 13-Jul-21 11:17 AM
DiscordのAPIが一部変わって、既存メッセージを編集するAPIへ渡すパラメータに省略出来ないものが追加されたらしく、編集に失敗してた。
今日は直せそうにないかな
Avatar
omochimetaru 13-Jul-21 11:24 AM
Discord APIの変更の関係だったのか
Avatar
Kishikawa Katsumi 13-Jul-21 11:28 AM
めっちゃ偶然の事象ですね😲ナイスデバッグだ。
Avatar
Iceman 13-Jul-21 11:40 AM
僕の操作のせいやった😂
Avatar
norio_nomura 13-Jul-21 12:34 PM
既存メッセージ削除APIは影響を受けていないので、ボットからの意図せぬ返事を残したくない場合は、メッセージ編集ではなく削除&新規投稿で回避できます。
👍 1
Avatar
kateinoigakukun 25-Jul-21 10:01 AM
@swift-5.4.3 @swift-5.3.3 @swift-nightly
protocol P0 {} extension P0 { func openExistential() -> some P0 { return self } } func use<T: P0>(_: T) {} func make() -> P0 { fatalError() } let p0 = make() _ = p0.openExistential()
Avatar
swift54 BOT 25-Jul-21 10:01 AM
exit status: 1 with stderr:
<stdin>:13:5: error: member 'openExistential' cannot be used on value of protocol type 'P0'; use a generic constraint instead _ = p0.openExistential() ^~ ~~~~~~~~~~~~~~~
Avatar
swiftNightly BOT 25-Jul-21 10:01 AM
exit status: 1 with stderr:
<stdin>:13:5: error: member 'openExistential' cannot be used on value of protocol type 'P0'; use a generic constraint instead _ = p0.openExistential() ^~ ~~~~~~~~~~~~~~~
Avatar
swift53 BOT 25-Jul-21 10:01 AM
exit status: 4 with stderr:
Fatal error: file main/<stdin>, line 10 Current stack trace: 0 libswiftCore.so 0x00007fc7d0e80df0 swift_reportError + 50 1 libswiftCore.so 0x00007fc7d0ef4160 _swift_stdlib_reportFatalErrorInFile + 115 2 libswiftCore.so 0x00007fc7d0bd9eb5 <unavailable> + 1400501 3 libswiftCore.so 0x00007fc7d0bd9af7 <unavailable> + 1399543 4 libswiftCore.so 0x00007fc7d0bda0e2 <unavailable> + 1401058 5 libswiftCore.so 0x00007fc7d0bd8530 _assertionFailure(_:_:file:line:flags:) + 517 8 swift 0x00000000005b4501 <unavailable> + 1787137 9 swift 0x00000000005a1d04 <unavailable> + 1711364 10 swift 0x0000000000587e88 <unavailable> + 1605256 11 swift 0x000000000057b322 <unavailable> + 1553186 12 swift 0x00000000005780ef <unavailable> + 1540335 13 swift 0x0000000000501c2c <unavailable> + 1055788 14 libc.so.6 0x00007fc7d2f4f740 __libc_start_main + 240 15 swift 0x00000000005017a9 <unavailable> + 1054633 Stack dump: 0. Program arguments: /usr/bin/swift -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -I /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -I /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/inc
Avatar
kateinoigakukun 25-Jul-21 10:02 AM
ORTでopen existentialできるか?と思ったけど制約付いてるっぽい
ただ、5.3.2だとコンパイル通っちゃうw
Avatar
omochimetaru 25-Jul-21 07:25 PM
実装はできるのか・・・
Avatar
rinsuki 27-Jul-21 03:43 AM
@swift-5.4.3
struct Hoge { var hoge, fuga: Int } print(Hoge(hoge: 1, fuga: 2))
Avatar
swift54 BOT 27-Jul-21 03:43 AM
Hoge(hoge: 1, fuga: 2)
Avatar
omochimetaru 28-Jul-21 07:51 AM
@swift-5.4.3
import Foundation func f(q: URLRequest) {}
Avatar
swift54 BOT 28-Jul-21 07:51 AM
exit status: 1 with stderr:
<stdin>:2:11: error: cannot find type 'URLRequest' in scope func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
omochimetaru 28-Jul-21 07:51 AM
??
@swift-5.1.5 @swift-5.2.5 @swift-5.3.3
import Foundation func f(q: URLRequest) {}
Avatar
swift53 BOT 28-Jul-21 07:51 AM
exit status: 1 with stderr:
<stdin>:2:11: error: cannot find type 'URLRequest' in scope func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
swift52 BOT 28-Jul-21 07:51 AM
exit status: 1 with stderr:
<stdin>:2:11: error: use of undeclared type 'URLRequest' func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
swift51 BOT 28-Jul-21 07:51 AM
exit status: 1 with stderr:
<stdin>:2:11: error: use of undeclared type 'URLRequest' func f(q: URLRequest) {} ^~~~~~~~~~
Avatar
kateinoigakukun 28-Jul-21 07:52 AM
FoundationNetworking
Avatar
omochimetaru 28-Jul-21 07:52 AM
@swift-5.1.5 @swift-5.2.5 @swift-5.3.3 @swift-5.4.3
import FoundationNetworking func f(q: URLRequest) {}
Avatar
swift51 BOT 28-Jul-21 07:52 AM
no output
Avatar
swift54 BOT 28-Jul-21 07:52 AM
no output
Avatar
swift53 BOT 28-Jul-21 07:52 AM
no output
Avatar
swift52 BOT 28-Jul-21 07:52 AM
no output
Avatar
omochimetaru 28-Jul-21 07:52 AM
えええ〜・・・・
mac/linuxでクロスなコード書けないじゃん
Avatar
kateinoigakukun 28-Jul-21 07:53 AM
#if canImport(FoundationNetworking) import FoundationNetworking #endif
をいたるところに貼り付けます…
Avatar
omochimetaru 28-Jul-21 07:53 AM
開発をXcode/macでやって、デプロイ先がLinuxだから、厳しいなあ (edited)
Avatar
kateinoigakukun 28-Jul-21 07:54 AM
そのシナリオでcanImportのやつ動きますよ
Avatar
omochimetaru 28-Jul-21 07:54 AM
canImportのやつを書かないといけない事に気づけない。 (edited)
Avatar
kateinoigakukun 28-Jul-21 07:54 AM
ああ
LinuxベースのCIがあれば…
Avatar
omochimetaru 28-Jul-21 07:55 AM
CIはあるので、そこでわかるね。
Avatar
Kishikawa Katsumi 28-Jul-21 07:55 AM
FoundationNetworkingはワナ
Avatar
omochimetaru 28-Jul-21 07:55 AM
罠でしかないですねこれ
Appleもmac側で追従してくれないと意味がない
Avatar
Iceman 28-Jul-21 07:56 AM
逆にCIで気づけてよかった
Avatar
kateinoigakukun 28-Jul-21 07:56 AM
実装空でもいいからFoundationNetworkingモジュール作って欲しい…
Avatar
Kishikawa Katsumi 28-Jul-21 07:57 AM
ほんまやなあ。
Avatar
omochimetaru 28-Jul-21 08:02 AM
dockerでビルド通ったのでCIに投げた。
Avatar
rinsuki 28-Jul-21 10:09 PM
毎回canImport書くのだるかったので https://github.com/rinsuki/FoundationWithNetworking を作ってしまった
no more #if canImport(FoundationNetworking). Contribute to rinsuki/FoundationWithNetworking development by creating an account on GitHub.
Avatar
nanasi 29-Jul-21 01:33 AM
@swift-5.1.5 @swift-5.4.3
import Foundation func foo() { struct Item<Content: Identifiable>: Equatable { let content: Content static func == (lhs: Item<Content>, rhs: Item<Content>) -> Bool { return lhs.content.id == rhs.content.id } } }
Avatar
swift54 BOT 29-Jul-21 01:33 AM
exit status: 1 with stderr:
<stdin>:4:12: error: type 'Item<Content>' does not conform to protocol 'Equatable' struct Item<Content: Identifiable>: Equatable { ^ <stdin>:5:13: note: stored property type 'Content' does not conform to protocol 'Equatable', preventing synthesized conformance of 'Item<Content>' to 'Equatable' let content: Content ^ Swift.==:1:24: note: candidate would match if 'Item<Content>' conformed to 'RawRepresentable' @inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.FloatingPoint:2:24: note: candidate would match if 'Item<Content>' conformed to 'FloatingPoint' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.BinaryInteger:2:24: note: candidate would match if 'Item<Content>' conformed to 'BinaryInteger' public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger ^ Swift._Pointer:2:24: note: candidate would match if 'Item<Content>' conformed to '_Pointer' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Strideable:3:35: note: candidate would match if 'Item<Content>' conformed to 'Strideable' @inlinable public static func == (x: Self, y: Self) -> Bool ^ Swift.StringProtocol:2:35: note: candidate would match if 'Item<Content>' conformed to 'StringProtocol' @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol ^ Swift.SIMD:4:24: note: candidate would match if 'Item<Content>' conformed to 'SIMD' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation.__BridgedNSError:2:24: note: candidate would match if 'Item<Content>' conformed to '__BridgedNSError' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation._Bri
Avatar
swift51 BOT 29-Jul-21 01:33 AM
exit status: 1 with stderr:
<stdin>:4:12: error: type 'Item<Content>' does not conform to protocol 'Equatable' struct Item<Content: Identifiable>: Equatable { ^ Swift.==:1:24: note: candidate would match if 'Item<Content>' conformed to 'RawRepresentable' @inlinable public func == <T>(lhs: T, rhs: T) -> Bool where T : RawRepresentable, T.RawValue : Equatable ^ Swift.FloatingPoint:2:24: note: candidate would match if 'Item<Content>' conformed to 'FloatingPoint' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.BinaryInteger:2:24: note: candidate would match if 'Item<Content>' conformed to 'BinaryInteger' public static func == <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger ^ Swift._Pointer:2:24: note: candidate would match if 'Item<Content>' conformed to '_Pointer' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Strideable:3:35: note: candidate would match if 'Item<Content>' conformed to 'Strideable' @inlinable public static func == (x: Self, y: Self) -> Bool ^ Swift.StringProtocol:2:35: note: candidate would match if 'Item<Content>' conformed to 'StringProtocol' @inlinable public static func == <RHS>(lhs: Self, rhs: RHS) -> Bool where RHS : StringProtocol ^ Swift.SIMD:4:24: note: candidate would match if 'Item<Content>' conformed to 'SIMD' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation.__BridgedNSError:2:24: note: candidate would match if 'Item<Content>' conformed to '__BridgedNSError' public static func == (lhs: Self, rhs: Self) -> Bool ^ Foundation._BridgedStoredNSError:2:24: note: candidate would match if 'Item<Content>' conformed to '_BridgedStoredNSError' public static func == (lhs: Self, rhs: Self) -> Bool ^ Swift.Equatable
Avatar
rintaro 29-Jul-21 11:24 PM
@swift-5.2.5 @swift-5.3.3
@propertyWrapper struct Wrap { var wrappedValue: Int = 1 } struct S { @Wrap var val }
(edited)
Avatar
swift52 BOT 29-Jul-21 11:25 PM
exit status: 1 with stderr:
<stdin>:6:13: error: type annotation missing in pattern @Wrap var val ^
Avatar
swift53 BOT 29-Jul-21 11:26 PM
no output
Avatar
rintaro 29-Jul-21 11:27 PM
https://github.com/apple/swift/pull/30663 property wrapper で var 宣言の型アノテーション省略できる
Avatar
kateinoigakukun 29-Jul-21 11:29 PM
SwiftUIの@Environment使う時にべんり
Avatar
koher 30-Jul-21 02:53 AM
前に SwiftUI の @Namespace で初めて見たとき、なんじゃこりゃってなった。
@Namespace private var foo
(edited)
Avatar
rinsuki 30-Jul-21 05:04 AM
@swift-nightly
func hoge() async {} Task { await hoge() }
Avatar
swiftNightly BOT 30-Jul-21 05:04 AM
no output
Avatar
lovee 02-Aug-21 06:52 AM
@swift-5.0.3
do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift50 BOT 02-Aug-21 06:52 AM
exit status: 1 with stderr:
<stdin>:3:9: warning: initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it let a = 0 ~~~~^ _ <stdin>:2:19: error: cannot capture 'a' before it is declared defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:3:9: note: 'a' declared here let a = 0 ^
Avatar
lovee 02-Aug-21 06:52 AM
@swift-5.1.5
do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift51 BOT 02-Aug-21 06:52 AM
exit status: 1 with stderr:
<stdin>:3:9: warning: initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it let a = 0 ~~~~^ _ <stdin>:2:19: error: cannot capture 'a' before it is declared defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:3:9: note: 'a' declared here let a = 0 ^
Avatar
lovee 02-Aug-21 06:52 AM
@swift-5.2.5
do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift52 BOT 02-Aug-21 06:52 AM
0
stderr:
<stdin>:3:9: warning: initialization of immutable value 'a' was never used; consider replacing with assignment to '_' or removing it let a = 0 ~~~~^ _
Avatar
lovee 02-Aug-21 06:59 AM
@swift-5.3.3
do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift53 BOT 02-Aug-21 06:59 AM
0
Avatar
lovee 02-Aug-21 06:59 AM
@swift-5.4.3
do { defer { print(a) } // ←まだaが宣言されてないよ…? let a = 0 }
Avatar
swift54 BOT 02-Aug-21 06:59 AM
0
Avatar
Ensan 02-Aug-21 07:23 AM
@swift-5.4.3
func foo() { defer { print(a) } // ←まだaが宣言されてないよ…? let a: Int? = 42 guard var a = a else { return } a = 20 } foo()
Avatar
swift54 BOT 02-Aug-21 07:23 AM
Optional(42)
stderr:
<stdin>:2:19: warning: expression implicitly coerced from 'Int?' to 'Any' defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:2:19: note: provide a default value to avoid this warning defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:2:19: note: force-unwrap the value to avoid this warning defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:2:19: note: explicitly cast to 'Any' with 'as Any' to silence this warning defer { print(a) } // ←まだaが宣言されてないよ…? <stdin>:4:15: warning: variable 'a' was written to, but never read guard var a = a else { return } ^
Avatar
koher 02-Aug-21 07:31 AM
@swift-5.4.3
func foo() { defer { print(a as Any) } // ←まだaが宣言されてないよ…? let a: Int? = 42 guard var a = a else { return } a = 20 } foo()
Avatar
swift54 BOT 02-Aug-21 07:31 AM
Optional(42)
stderr:
<stdin>:4:15: warning: variable 'a' was written to, but never read guard var a = a else { return } ^
Avatar
koher 02-Aug-21 07:33 AM
@swift-5.4.3
func foo() { defer { print(a as Any) } // ←まだaが宣言されてないよ…? var a: Int? = 42 guard let b = a else { return } a = b + 1 } foo()
Avatar
swift54 BOT 02-Aug-21 07:33 AM
Optional(42)
Avatar
koher 02-Aug-21 07:34 AM
@swift-5.4.3
func foo() { defer { print(a) } // ←まだaが宣言されてないよ…? var a: Int = 42 a += 1 } foo()
Avatar
swift54 BOT 02-Aug-21 07:34 AM
0
Avatar
koher 02-Aug-21 07:36 AM
@swift-5.4.3
func foo() { defer { // まだaが宣言されてないよ…? a += 2 print(a) } var a: Int = 42 a += 1 } foo()
Avatar
swift54 BOT 02-Aug-21 07:36 AM
2
Avatar
Iceman 02-Aug-21 07:50 AM
最終的に実行される場所でのスコープを見るのかと思ったら、知らないところから変数を持ってきてる
Avatar
koher 02-Aug-21 07:59 AM
これ、変数宣言前の defer での利用ができてしまっていること自体がバグなのかな?昔の挙動が正しかった?
Avatar
omochimetaru 02-Aug-21 08:01 AM
ウケるw
Avatar
Iceman 02-Aug-21 08:05 AM
@swift-5.4.3
class C { var a: Int = 1 func f() { let _ = (0...2).map { _ -> Int in _ = a return 1 } let a = 2 } }
Avatar
swift54 BOT 02-Aug-21 08:05 AM
exit status: 1 with stderr:
<stdin>:4:25: error: closure captures 'a' before it is declared let _ = (0...2).map { _ -> Int in ^ <stdin>:8:9: note: captured value declared here let a = 2 ^ <stdin>:5:11: note: captured here _ = a ^
Avatar
Iceman 02-Aug-21 08:06 AM
前に見つけたやつだけどこれもローカル変数が前方に持ち上げられてる
(本来はプロパティのa もあるので使えるはず) (edited)
Avatar
masakihori 02-Aug-21 08:11 AM
classを使うことでコンパイラを殺せた
@swift-5.4.3
class A { var i: Int init(_ i: Int) { self.i = i } } func f() -> A { defer { a.i = 10 } let a = A(3) return a } print(f())
Avatar
swift54 BOT 02-Aug-21 08:12 AM
exit status: 134 with stderr:
Begin Error in Function: '$s4main1fAA1ACyF' Found outside of lifetime use?! Value: %6 = apply %5(%4, %0) : $@convention(method) (Int, @thick A.Type) -> @owned A // users: %12, %11, %8, %7 Consuming User: destroy_value %6 : $A // id: %11 Non Consuming User: %12 = begin_borrow %6 : $A // users: %15, %14 Block: bb0 End Error in Function: '$s4main1fAA1ACyF' Found ownership error?! triggering standard assertion failure routine UNREACHABLE executed at /home/buildnode/jenkins/workspace/oss-swift-5.4-package-linux-ubuntu-16_04/swift/lib/SIL/Verifier/LinearLifetimeCheckerPrivate.h:211! Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xc
Avatar
Iceman 02-Aug-21 08:12 AM
Avatar
tarunon 02-Aug-21 10:11 AM
ホンモノのヌルポなのでは
Avatar
omochimetaru 02-Aug-21 12:45 PM
@swift-nightly
func foo() { defer { // まだaが宣言されてないよ…? a += 2 print(a) } var a: Int = 42 a += 1 } foo()
Avatar
swiftNightly BOT 02-Aug-21 12:45 PM
exit status: 1 with stderr:
<stdin>:4:9: error: use of local variable 'a' before its declaration a += 2 ^ <stdin>:7:9: note: 'a' declared here var a: Int = 42 ^ <stdin>:5:15: error: use of local variable 'a' before its declaration print(a) ^ <stdin>:7:9: note: 'a' declared here var a: Int = 42 ^
Avatar
omochimetaru 02-Aug-21 12:45 PM
nightlyで治ってる案件か
Avatar
Ensan 02-Aug-21 01:03 PM
@swift-5.4.3
struct Test { @available(iOS 16, *) var a: Int { 42 } func test() { if #available(macOS 11, *) { print(a) } } } Test().test()
Avatar
swift54 BOT 02-Aug-21 01:03 PM
42
Avatar
Ensan 02-Aug-21 01:03 PM
@swift-5.4.3
struct Test { @available(iOS 16, *) var a: Int { 42 } func test() { print(a) } } Test().test()
Avatar
swift54 BOT 02-Aug-21 01:03 PM
42
Avatar
omochimetaru 03-Aug-21 04:58 AM
@swift-5.3.3 @swift-5.4.3 @swift-nightly
protocol P { associatedtype T } protocol Q: P { typealias T = Int } func f(q: Q) {}
Avatar
swift53 BOT 03-Aug-21 04:58 AM
exit status: 1 with stderr:
<stdin>:6:13: warning: typealias overriding associated type 'T' from protocol 'P' is better expressed as same-type constraint on the protocol typealias T = Int ~~~~~~~~~~^~~~~~~ <stdin>:2:18: note: 'T' declared here associatedtype T ^ <stdin>:9:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
swift54 BOT 03-Aug-21 04:58 AM
exit status: 1 with stderr:
<stdin>:6:13: warning: typealias overriding associated type 'T' from protocol 'P' is better expressed as same-type constraint on the protocol typealias T = Int ~~~~~~~~~~^~~~~~~ <stdin>:2:18: note: 'T' declared here associatedtype T ^ <stdin>:9:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
swiftNightly BOT 03-Aug-21 04:58 AM
exit status: 1 with stderr:
<stdin>:6:13: warning: typealias overriding associated type 'T' from protocol 'P' is better expressed as same-type constraint on the protocol typealias T = Int ~~~~~~~~~~^~~~~~~ <stdin>:2:18: note: 'T' declared here associatedtype T ^ <stdin>:9:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
omochimetaru 03-Aug-21 04:59 AM
@swift-nightly
protocol P { associatedtype T } protocol Q: P where T = Int { } func f(q: Q) {}
Avatar
swiftNightly BOT 03-Aug-21 04:59 AM
exit status: 1 with stderr:
<stdin>:5:23: error: use '==' for same-type requirements rather than '=' protocol Q: P where T = Int { ^ == <stdin>:8:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
omochimetaru 03-Aug-21 04:59 AM
@swift-nightly
protocol P { associatedtype T } protocol Q: P where T == Int { } func f(q: Q) {}
Avatar
swiftNightly BOT 03-Aug-21 04:59 AM
exit status: 1 with stderr:
<stdin>:8:11: error: protocol 'Q' can only be used as a generic constraint because it has Self or associated type requirements func f(q: Q) {} ^
Avatar
omochimetaru 03-Aug-21 05:00 AM
あれ、確定して埋まってればexistentialとして使えるやつってまだだったっけ
確定してればじゃないか、メンバが潰れるだけでなんでもいけるようになったのか
Avatar
tarunon 03-Aug-21 05:01 AM
確定してればメンバも見えるだったような
Avatar
omochimetaru 03-Aug-21 05:02 AM
3ヶ月前にSE statusはacceptedになってるけど実装がdraft PRだ・・・
review前に実装は用意したがマージできるとは言っていないやつか あらー
Avatar
t.ae 03-Aug-21 08:31 AM
@swift-5.4.3
struct Foo { var x: Int func test() { let x = x + 1 print(x) } }
Avatar
swift54 BOT 03-Aug-21 08:31 AM
no output
Avatar
t.ae 03-Aug-21 08:32 AM
@swift-5.3.3
struct Foo { var x: Int func test() { let x = x + 1 print(x) } }
Avatar
swift53 BOT 03-Aug-21 08:32 AM
exit status: 1 with stderr:
<stdin>:5:17: error: variable used within its own initial value let x = x + 1 ^
Avatar
t.ae 03-Aug-21 08:33 AM
これ5.4でなおってるのか……
Avatar
Ensan 03-Aug-21 08:34 AM
@swift-nightly
protocol P {} struct A { var p: some P = A() }
Avatar
swiftNightly BOT 03-Aug-21 08:34 AM
exit status: 1 with stderr:
<stdin>:3:21: error: return type of property 'p' requires that 'A' conform to 'P' var p: some P = A() ^ <stdin>:3:12: note: opaque return type declared here var p: some P = A() ^~~~~~ <stdin>:3:9: error: property declares an opaque return type, but cannot infer the underlying type from its initializer expression var p: some P = A() ^
Avatar
Ensan 03-Aug-21 08:35 AM
@swift-nightly
protocol P {} struct A: P { var p: some P = A() }
Avatar
swiftNightly BOT 03-Aug-21 08:35 AM
exit status: 11 with stderr:
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-name main -lLib
👀 1
Avatar
tarunon 09-Aug-21 12:06 PM
@swift-5.4.3
extension String { func foo() {} } "".foo()
Avatar
swift54 BOT 09-Aug-21 12:06 PM
no output
Avatar
Ensan 09-Aug-21 12:09 PM
@swift-5.4.3
extension String { private func foo() {} } "".foo()
(edited)
Avatar
swift54 BOT 09-Aug-21 12:09 PM
exit status: 1 with stderr:
<stdin>:5:4: error: 'foo' is inaccessible due to 'private' protection level "".foo() ^~~ <stdin>:2:16: note: 'foo()' declared here private func foo() {} ^
Avatar
tarunon 09-Aug-21 12:09 PM
あっ、privateつけわすれてたw
Avatar
koher 09-Aug-21 01:19 PM
@swift-5.4.3
final class ViewController { func viewDidLoad() { prepareViews() } } extension ViewController { private func prepareViews() { prepareAView() prepareBView() prepareCView() } /*extension*/private func prepareAView() {} /*extension*/private func prepareBView() {} /*extension*/private func prepareCView() {} }
Avatar
swift54 BOT 09-Aug-21 01:19 PM
no output
Avatar
koher 09-Aug-21 01:19 PM
@swift-5.4.3
final class ViewController { func viewDidLoad() { prepareViews() // ↓これはできてほしくない prepareAView() } } extension ViewController { private func prepareViews() { prepareAView() prepareBView() prepareCView() } /*extension*/private func prepareAView() {} /*extension*/private func prepareBView() {} /*extension*/private func prepareCView() {} }
Avatar
swift54 BOT 09-Aug-21 01:19 PM
no output
Avatar
Iceman 12-Aug-21 09:38 AM
@swift-5.4.3
print(Bundle.main.bundleURL)
Avatar
swift54 BOT 12-Aug-21 09:38 AM
exit status: 1 with stderr:
<stdin>:1:7: error: cannot find 'Bundle' in scope print(Bundle.main.bundleURL) ^~~~~~
Avatar
Iceman 12-Aug-21 09:38 AM
@swift-5.4.3
import Foundation print(Bundle.main.bundleURL)
Avatar
swift54 BOT 12-Aug-21 09:38 AM
file:///usr/bin/
Avatar
t.ae 16-Aug-21 07:15 AM
@swift-5.4.3
import Foundation enum Key: String, Codable { case a, b } let data = [Key.a: "A", Key.b: "B"] let json = try String(data: JSONEncoder().encode(data), encoding: .utf8)! print(json)
Avatar
swift54 BOT 16-Aug-21 07:15 AM
["b","B","a","A"]
Avatar
t.ae 16-Aug-21 07:15 AM
これって正しいんでしょうか?
Avatar
Iceman 16-Aug-21 07:24 AM
jsonのkeyは文字列であることが必須で、Stringは特別に文字列であるとみなされてkeyValueになるけど、RawRepresentableはそこ特別にハンドルされてなかった気がする Swift的にはArrayからDictionaryに戻せるのでそっちの動きが優先されてる
Avatar
omochimetaru 16-Aug-21 07:24 AM
正しいというかそういう仕様だよ
一般のDictionaryのcodingは、[k1, v1, k2, v2, ... ]だから。
keyがString のときだけ 辞書になる
Avatar
t.ae 16-Aug-21 07:25 AM
確かに普通にデコードできますね。 keyがStringのときのみの制限は知らなかったです……
Avatar
omochimetaru 16-Aug-21 07:26 AM
あと Int
それ以外の型でも辞書形式にコーディングするかどうか制御できるAPIが欲しいって話題は最近もフォーラムに書き込みがあった気がする
Avatar
omochimetaru 03-Sep-21 04:57 AM
@swift-nightly @swift-5.4.3 @swift-5.3.3 @swift-5.2.5
protocol P { func foo() } struct S: P { func foo() {} } func nopConsumeP(_ p: P) {} func useAny(_ x: Any) { if let p = x as? P { nopConsumeP(p) } else { print("キャスト失敗!") } } func useOptionalT(_ x: T?) { useAny(x as Any) } useOptionalT(T())
Avatar
swift52 BOT 03-Sep-21 04:57 AM
exit status: 1 with stderr:
<stdin>:19:24: error: use of undeclared type 'T' func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: use of unresolved identifier 'T' useOptionalT(T()) ^
Avatar
swift54 BOT 03-Sep-21 04:57 AM
exit status: 1 with stderr:
<stdin>:19:24: error: cannot find type 'T' in scope func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: cannot find 'T' in scope useOptionalT(T()) ^
Avatar
swiftNightly BOT 03-Sep-21 04:57 AM
exit status: 1 with stderr:
<stdin>:19:24: error: cannot find type 'T' in scope func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: cannot find 'T' in scope useOptionalT(T()) ^
Avatar
swift53 BOT 03-Sep-21 04:57 AM
exit status: 1 with stderr:
<stdin>:19:24: error: cannot find type 'T' in scope func useOptionalT(_ x: T?) { ^ <stdin>:23:14: error: cannot find 'T' in scope useOptionalT(T()) ^
Avatar
omochimetaru 03-Sep-21 04:58 AM
@swift-nightly @swift-5.4.3 @swift-5.3.3 @swift-5.2.5
protocol P { func foo() } struct S: P { func foo() {} } func nopConsumeP(_ p: P) {} func useAny(_ x: Any) { if let p = x as? P { nopConsumeP(p) } else { print("キャスト失敗!") } } func useOptionalS(_ x: S?) { useAny(x as Any) } useOptionalS(S())
Avatar
swift52 BOT 03-Sep-21 04:58 AM
キャスト失敗!
Avatar
swiftNightly BOT 03-Sep-21 04:58 AM
no output
Avatar
swift54 BOT 03-Sep-21 04:58 AM
no output
Avatar
swift53 BOT 03-Sep-21 04:58 AM
キャスト失敗!
Avatar
omochimetaru 03-Sep-21 04:59 AM
Avatar
kateinoigakukun 03-Sep-21 05:02 AM
これかな?
あれ、botとwebの結果が違うのか
Avatar kateinoigakukun
これかな?
Avatar
omochimetaru 03-Sep-21 05:03 AM
それかもしれない。 今、手元のmacの5.4.2では通って、GitHub Action の CI 5.4.0 では落ちて
「キャスト成功」を出してないだけで結果は同じだよ
Avatar
kateinoigakukun 03-Sep-21 05:03 AM
そんなことなかった
Avatar
omochimetaru 03-Sep-21 05:03 AM
botでは5.4.2しかないから、fiddleで5.4.1と5.4.0を見てきた
Avatar
kateinoigakukun 03-Sep-21 05:04 AM
macOSはむずいですよ
Avatar
omochimetaru 03-Sep-21 05:04 AM
コンパイラ的には5.4.0と5.4.2で同じ挙動なので
CIがCatalinaで、ローカルがBigSurであることによる
挙動の違いじゃないかというところまで来たところ
Avatar
kateinoigakukun 03-Sep-21 05:04 AM
ロードするランタイムのちがいですね
dyldの環境変数でロードするランタイムのバージョン合わせると挙動一致すると思います
Avatar
omochimetaru 03-Sep-21 05:05 AM
やっぱそうなん?ランタイム関数のバックパッチ機能はなんで働いてないん?
Avatar
kateinoigakukun 03-Sep-21 05:07 AM
コンパイルするときにコンパチブルランタイムバージョン指定してないとか?
Avatar
omochimetaru 03-Sep-21 05:10 AM
Package.swiftに
platforms: [ .macOS(.v10_15) ],
ってかいた以外のことはしてない
iOSじゃなくてサーバーサイドswift
Avatar
kateinoigakukun 03-Sep-21 05:12 AM
その指定してても--runtime-compatibility-versionオプション渡してくれないんでしたっけ
Avatar
omochimetaru 03-Sep-21 05:13 AM
なにもしらないです。
とにかくそれが指定されていないと、フックは出荷されないということかな
Avatar
kateinoigakukun 03-Sep-21 05:13 AM
はい
いや、でも渡すターゲットトリプルによって適切にフック挿入してるように見えるな
Avatar
omochimetaru 03-Sep-21 05:17 AM
CIをbigsurにしたらキャストの挙動が期待通りになった。
原因はOS違いで確定した。 (edited)
Avatar
kateinoigakukun 03-Sep-21 05:18 AM
おー
Avatar
omochimetaru 03-Sep-21 05:18 AM
忙しいのでフックがなんでうまくいかなかったかとかは今は置いときます 情報ありがとう
Avatar
kateinoigakukun 03-Sep-21 05:20 AM
フック問題は宿題だ
Avatar
omochimetaru 03-Sep-21 05:21 AM
幸い、デプロイ先のLinuxのほうが心配が少ないw (edited)
Avatar
kateinoigakukun 03-Sep-21 05:21 AM
やっぱりmacOSは難しい
Avatar
nanasi 15-Sep-21 01:54 AM
@swift-nightly @swift-5.4.3
@available(macOS 12, *) public struct Crayon {} public enum Pen { case pencil @available(macOS 12, *) case crayon(Crayon) }
Avatar
swift54 BOT 15-Sep-21 01:54 AM
no output
Avatar
swiftNightly BOT 15-Sep-21 01:54 AM
no output
Avatar
norio_nomura 15-Sep-21 03:53 AM
@swift-5.5.3 -version @swift-5.5.3
print("hello")
(edited)
Avatar norio_nomura
@swift-5.5.3 -version @swift-5.5.3
print("hello")
(edited)
Avatar
swift55 BOT 15-Sep-21 03:53 AM
swift -version -
Swift version 5.5-dev (LLVM 5ac425fe8b983a2, Swift e6826e3cbcf5c16) Target: x86_64-unknown-linux-gnu
(edited)
Avatar norio_nomura
@swift-5.5.3 -version @swift-5.5.3
print("hello")
(edited)
Avatar
swift55 BOT 15-Sep-21 03:53 AM
swift -
hello
Avatar
norio_nomura 15-Sep-21 03:54 AM
@swift40 のインスタンスを @swift55 へ変えました。
👏 2
同時にボットアプリ自体もSwiftからDenoに書き換えました。
Avatar
kateinoigakukun 15-Sep-21 03:58 AM
JSだとdiscord-apiライブラリが信頼できそうですね
Avatar
norio_nomura 15-Sep-21 04:03 AM
信頼性はどうだろう?
discord.jsではないので。
Avatar
kateinoigakukun 15-Sep-21 04:03 AM
あれ、そうなんですか
なるほどdiscordenoってやつがあるんですね (edited)
Avatar
norio_nomura 15-Sep-21 04:05 AM
そうそれ。
Swift以外のCLIにも流用できる形にした https://github.com/norio-nomura/cli_discord_bot
CLI Discord Bot. Contribute to norio-nomura/cli_discord_bot development by creating an account on GitHub.
👏 1
Avatar
norio_nomura 15-Sep-21 04:17 AM
以前のものと違う点 // 追加 - リプライによるメンション元の追跡 - 同じボットへの複数コマンド発行(-O-Ononeの比較とか。) - 公開スレッド/非公開スレッドチャンネルに対応 // 未実装 - インポート可能モジュールの提供(swift-NIOとか) - 長文ログのアップロード (edited)
とりあえず @swift55 だけが新しいコードで動いてて、それ以外は以前のままです。
@swift55をしばらく使ってみて、問題なさそうなら他も更新していきます。
👏 1
Avatar
koher 16-Sep-21 03:40 AM
@swift-5.1.5 @swift-5.4.3
func main() { let a: Int? = 42 guard let a = a else { return } print(a) } main()
Avatar
swift54 BOT 16-Sep-21 03:40 AM
42
Avatar
swift51 BOT 16-Sep-21 03:40 AM
exit status: 1 with stderr:
<stdin>:3:15: error: definition conflicts with previous value guard let a = a else { return } ^ <stdin>:2:9: note: previous definition of 'a' is here let a: Int? = 42 ^ <stdin>:4:11: warning: expression implicitly coerced from 'Int?' to 'Any' print(a) ^ <stdin>:4:11: note: provide a default value to avoid this warning print(a) ^ ?? <#default value#> <stdin>:4:11: note: force-unwrap the value to avoid this warning print(a) ^ ! <stdin>:4:11: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(a) ^ as Any <stdin>:3:15: warning: value 'a' was defined but never used; consider replacing with boolean test guard let a = a else { return } ~~~~^~~~ != nil
Avatar
omochimetaru 16-Sep-21 03:41 AM
5.4からそれできるんだ
Avatar
koher 16-Sep-21 03:41 AM
そう、 5.5 からかと思ってた。
Avatar
omochimetaru 16-Sep-21 03:41 AM
結構やりたいことあって、しかたなく let aOrNone にしてたから助かるなー
Avatar
koher 16-Sep-21 03:41 AM
今たまたま 5.4 でアプリのコード書いててできたから、もうできたんだっけ?と思って。
5.4.2でできるようになったのかな・・・。
5.4の頃はできなかったような?
Avatar
omochimetaru 16-Sep-21 03:45 AM
5.4.0からできるみたい
Avatar
koher 16-Sep-21 03:45 AM
そうなんだ。
Avatar
Iceman 16-Sep-21 04:19 AM
@swift-5.4.3
func main() { guard let _ = Int?.none else { preconditionFailure("preconditionFailure!") } print("hello") } main()
Avatar
swift54 BOT 16-Sep-21 04:19 AM
exit status: 4 with stderr:
main/<stdin>:4: Fatal error: preconditionFailure! Current stack trace: 0 libswiftCore.so 0x00007f1c29b157b0 swift_reportError + 50 1 libswiftCore.so 0x00007f1c29b89d30 _swift_stdlib_reportFatalErrorInFile + 112 2 libswiftCore.so 0x00007f1c29873320 _assertionFailure(_:_:file:line:flags:) + 1329 5 swift-frontend 0x00000000005a07e5 <unavailable> + 1705957 6 swift-frontend 0x000000000056a1de <unavailable> + 1483230 7 swift-frontend 0x000000000053a902 <unavailable> + 1288450 8 swift-frontend 0x0000000000539f6c <unavailable> + 1285996 9 swift-frontend 0x000000000052e445 <unavailable> + 1238085 10 swift-frontend 0x00000000004b8d98 <unavailable> + 757144 11 libc.so.6 0x00007f1c2bbc4740 __libc_start_main + 240 12 swift-frontend 0x00000000004b8869 <unavailable> + 755817 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/includ
Avatar
Iceman 16-Sep-21 04:20 AM
@swift-5.4.3 -Ounchecked
func main() { guard let _ = Int?.none else { preconditionFailure("preconditionFailure!") } print("hello") } main()
Avatar
swift54 BOT 16-Sep-21 04:20 AM
exit status: 11 with stderr:
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -I /Libraries/.build/x86_64-unknown-linux-gnu/debug -module-cache-path /Libraries/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -Ounchecked -D DEBUG -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/CSwiftBacktrace/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/SwiftBacktrace/Sources/Clibunwind/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOSHA1.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOSHA1/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOHTTPParser.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOHTTPParser/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/Libraries/.build/x86_64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /Libraries/.build/checkouts/swift-nio/Sources/CNIOLinux/include -module-name main -lLibraries 1. Swift version 5.4.2 (swift-5.4.2-RELEASE) 2.
Avatar
omochimetaru 16-Sep-21 04:20 AM
謎死になった。
でもこれだと、確定で死ぬからmainごと消したれ、みたいな最適化が起きる可能性もありそう。
Avatar
koher 16-Sep-21 04:28 AM
precondition は消えるけど preconditionFailure は消えなかったはず。
Avatar
omochimetaru 16-Sep-21 04:28 AM
消えてるからログが出てないのでは?
オプション無しのときは main/<stdin>:4: Fatal error: preconditionFailure! という出力があります。
Avatar
kateinoigakukun 16-Sep-21 04:29 AM
preconditionFailureの中の何かが消えたのかな
Avatar
omochimetaru 16-Sep-21 04:29 AM
クラッシュしてるってことは死ぬ命令だけは残ってるのか
Avatar
kateinoigakukun 16-Sep-21 04:30 AM
まー命令見るのが確実ですね
Avatar
koher 16-Sep-21 04:31 AM
どこかで -Ouncheckedprecondition は消えるけど preconditionFailure は消えない○×表見た気がするんだけどなぁ。どこだろう・・・。
ログの中身は -Onone-O でも変わったはずだからそういうもので、クラッシュする部分は残ってるとか?
Avatar
omochimetaru 16-Sep-21 04:33 AM
まあ、 guard なので
突き抜ける先も特に無いですからね
Avatar
koher 16-Sep-21 04:34 AM
In -Ounchecked builds, the optimizer may assume that this function is never called.
https://developer.apple.com/documentation/swift/1539374-preconditionfailure
仕様上は消えてもいいのかな。
Avatar
omochimetaru 16-Sep-21 04:35 AM
多分クラッシュする部分は残しておいたほうが
フロー解析でデッドエンドが検出できるんで得ですよね
何も考えずに全く関係ない次のラベルにフォールスルーするコードになっちゃってると
むしろ元のコードよりフローの繋がりが複雑になってしまう
LLVM IR におけるBasicBlockの接続グラフが変わっちゃうというか。
Avatar
koher 16-Sep-21 04:36 AM
precondition と違って preconditionFailure は分岐して使うことが前提となってるし、そうかも。
Avatar
Iceman 16-Sep-21 06:40 AM
@swift-5.4.3
print([1, "hoge"].description)
Avatar
swift54 BOT 16-Sep-21 06:40 AM
[1, "hoge"]
Avatar
norio_nomura 21-Sep-21 12:29 AM
@swift-5.5.3 -O @swift-5.5.3 -Onone
print(x) var x = 32
(edited)
Avatar norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone
print(x) var x = 32
(edited)
Avatar
swift55 BOT 21-Sep-21 12:29 AM
swift -O -
32
(edited)
Avatar norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone
print(x) var x = 32
(edited)
Avatar
swift55 BOT 21-Sep-21 12:29 AM
swift -Onone -
0
(edited)
Avatar
norio_nomura 21-Sep-21 12:36 AM
The variables in top-level code behave weirdly. They are declared in the global scope, but are initialized serially, like local variables in a normal function. This allows some interesting pieces of code to compile, such as: print(x) var x = 32 This program will print 0. The basic value types are automatically initialized, so they have a value...
Avatar norio_nomura
@swift55をしばらく使ってみて、問題なさそうなら他も更新していきます。
Avatar
Iceman 21-Sep-21 04:46 AM
@swift-x.x.x ```swift という感じでメンションと同じ行にコードを書き始めると今まではいけてたのですが新しいものではエラーになったようです。元々が仕様じゃなかったという感じでしょうか?
Avatar
norio_nomura 21-Sep-21 05:01 AM
その入力形式には以前対応しましたが、今回の書き換え時に意図せず変えてしまった様です。直します。
🙏 1
Avatar
Avatar
norio_nomura 21-Sep-21 09:46 AM
@Iceman報告ありがとうございました。
Avatar norio_nomura
@Iceman報告ありがとうございました。
Avatar
Iceman 21-Sep-21 09:49 AM
修正ありがとうございます!
👍 1
Avatar
norio_nomura 22-Sep-21 12:08 AM
@swift-5.5.3 -version
Avatar norio_nomura
@swift-5.5.3 -version
Avatar
swift55 BOT 22-Sep-21 12:08 AM
Swift version 5.5 (swift-5.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Ensan 23-Sep-21 01:41 AM
@swift-5.5.3
var count = 0 loop: do { print(count) count += 1 if count >= 10 { break loop } continue loop }
Avatar Ensan
@swift-5.5.3
var count = 0 loop: do { print(count) count += 1 if count >= 10 { break loop } continue loop }
Avatar
swift55 BOT 23-Sep-21 01:41 AM
0 1 2 3 4 5 6 7 8 9
Avatar
rintaro 24-Sep-21 06:06 PM
@swift-4.2.4 -frontend -emit-sil
public protocol BaseP { func foo() } public protocol DerivedP: BaseP { func foo() } public struct Concrete: DerivedP { public func foo() {} }
(edited)
Avatar
swift42 BOT 24-Sep-21 06:08 PM
sil_stage canonical import Builtin import Swift import SwiftShims public protocol BaseP { func foo() } public protocol DerivedP : BaseP { func foo() } public struct Concrete : DerivedP { public func foo() init() } // main sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 { bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>): %2 = integer_literal $Builtin.Int32, 0 // user: %3 %3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4 return %3 : $Int32 // id: %4 } // end sil function 'main' // Concrete.foo() sil @$S4main8ConcreteV3fooyyF : $@convention(method) (Concrete) -> () { // %0 // user: %1 bb0(%0 : $Concrete): debug_value %0 : $Concrete, let, name "self", argno 1 // id: %1 %2 = tuple () // user: %3 return %2 : $() // id: %3 } // end sil function '$S4main8ConcreteV3fooyyF' // protocol witness for DerivedP.foo() in conformance Concrete sil shared [transparent] [serialized] [thunk] @$S4main8ConcreteVAA8DerivedPA2aDP3fooyyFTW : $@convention(witness_method: DerivedP) (@in_guaranteed Concrete) -> () { // %0 // user: %1 bb0(%0 : $*Concrete): %1 = load %0 : $*Concrete // user: %3 // function_ref Concrete.foo() %2 = function_ref @$S4main8ConcreteV3fooyyF : $@convention(method) (Concrete) -> () // user: %3 %3 = apply %2(%1) : $@convention(method) (Concrete) -> () %4 = tuple () // user: %5 return %4 : $() // id: %5 } // end sil function '$S4main8ConcreteVAA8DerivedPA2aDP3fooyyFTW' // protocol witness for BaseP.foo() in conformance Concrete sil shared [transparent] [serialized] [thunk] @$S4main8ConcreteVAA5BasePA2aDP3fooyyFTW : $@convention(witness_method: BaseP) (@
Avatar
Iceman 28-Sep-21 04:44 AM
@swift-5.5.3
actor State { var value = 0 func inc() -> Int { defer { value += 1 } return value } } Task { let state = State() let stream = AsyncStream<Int> { let v = await state.inc() print("produce", v) return v } onCancel: { @Sendable in print("cancel") } var count = 0 for await aa in stream { count += 1 if count > 10 { break } print("for", aa) await Task.sleep(1 * 1000 * 1000 * 1000) } }
Avatar Iceman
@swift-5.5.3
actor State { var value = 0 func inc() -> Int { defer { value += 1 } return value } } Task { let state = State() let stream = AsyncStream<Int> { let v = await state.inc() print("produce", v) return v } onCancel: { @Sendable in print("cancel") } var count = 0 for await aa in stream { count += 1 if count > 10 { break } print("for", aa) await Task.sleep(1 * 1000 * 1000 * 1000) } }
Avatar
swift55 BOT 28-Sep-21 04:44 AM
produce 0 for 0
Avatar
norio_nomura 30-Sep-21 04:49 AM
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift52 BOT 30-Sep-21 04:49 AM
Swift version 5.2.5 (swift-5.2.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift55 BOT 30-Sep-21 04:49 AM
Swift version 5.5-dev (LLVM 87f91d38709ee59, Swift 5e0d32b7a898616) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift51 BOT 30-Sep-21 04:49 AM
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift50 BOT 30-Sep-21 04:49 AM
Swift version 5.0.3 (swift-5.0.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift42 BOT 30-Sep-21 04:49 AM
Swift version 4.2.4 (swift-4.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift54 BOT 30-Sep-21 04:49 AM
Swift version 5.4.3 (swift-5.4.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift41 BOT 30-Sep-21 04:49 AM
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swift53 BOT 30-Sep-21 04:49 AM
Swift version 5.3.3 (swift-5.3.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar norio_nomura
@swift-nightly @swift-5.5.3 @swift-5.4.3 @swift-5.3.3 @swift-5.2.5 @swift-5.1.5 @swift-5.0.3 @swift-4.2.4 @swift-4.1.3 -version
Avatar
swiftNightly BOT 30-Sep-21 04:49 AM
Swift version 5.6-dev (LLVM 063fb68c1307e0b, Swift 14eefd1162036b8) Target: x86_64-unknown-linux-gnu
Avatar
norio_nomura 30-Sep-21 04:49 AM
Swiftコンパイラボット全てをDeno版を使うように更新しました。 (edited)
👀 1
ボットのDiscordトークン抜き放題バグを塞ぎました 😓
Avatar
omochimetaru 30-Sep-21 04:51 AM
そんなバグがあったんですか
Avatar
norio_nomura 30-Sep-21 04:53 AM
もし、僕が作ったボットを元にしたものをここ以外で使っている場合は、更新することをお勧めします。
Avatar
omochimetaru 30-Sep-21 04:54 AM
昔岸川さんのbotが乗っ取られた事があったけど、関係あるんだろうか。
Avatar
norio_nomura 30-Sep-21 04:55 AM
今のところ悪用された形跡は無いので、関係ないんじゃ無いかな。
Avatar
omochimetaru 30-Sep-21 04:55 AM
なるほど。
Avatar
norio_nomura 30-Sep-21 04:57 AM
コードに起因するバグではなく、デプロイに問題がありました。
Avatar
norio_nomura 30-Sep-21 05:09 AM
2018年頃ボットを運用し始めた時から存在したはずなので、今までよくぞ見逃してもらえていたな、といった感じ。 (edited)
Avatar
omochimetaru 30-Sep-21 05:09 AM
逆にどうやって気がついたんですか?
Avatar
norio_nomura 30-Sep-21 05:14 AM
cli_discord_botに、他の常時起動していないボットアカウント向けメンションを監視して、Webアクセス経由でそのボットを起こす機能を追加できないか検討していて、設定が多くなってきて、設定方法をどうするか検討していて気づきました。
Avatar
omochimetaru 30-Sep-21 05:15 AM
なるほど〜
Avatar
norio_nomura 03-Oct-21 09:35 AM
ボット自動アップデートを復活させました。
👍 1
Avatar norio_nomura
ボットのDiscordトークン抜き放題バグを塞ぎました 😓
Avatar
norio_nomura 04-Oct-21 12:57 AM
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるので、Herokuの設定から環境変数経由で渡されたDiscordトークンを読み出せてた。 (edited)
😱 1
環境変数に残らないよう変えた。 @swift-nightly
import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/environ")))
(edited)
Avatar norio_nomura
環境変数に残らないよう変えた。 @swift-nightly
import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/environ")))
(edited)
Avatar
swiftNightly BOT 04-Oct-21 12:58 AM
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binDENO_TLS_CA_STORE=system
Avatar
norio_nomura 04-Oct-21 01:02 AM
ボットがリプライに含まれるメンションに反応しないな… 直しました。 (edited)
Avatar norio_nomura
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるので、Herokuの設定から環境変数経由で渡されたDiscordトークンを読み出せてた。 (edited)
Avatar
norio_nomura 04-Oct-21 01:40 AM
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるのは、これはHerokuの制限なので今も変わらず。
Avatar swiftNightly
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binDENO_TLS_CA_STORE=system
Avatar
norio_nomura 04-Oct-21 02:08 AM
ちなみにコマンドラインも簡単に取れるので、設定は標準入力経由で渡してる。 @swift-nightly
import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/cmdline")))
Avatar norio_nomura
ちなみにコマンドラインも簡単に取れるので、設定は標準入力経由で渡してる。 @swift-nightly
import Foundation print(try! String(contentsOf: URL(fileURLWithPath: "/proc/3/cmdline")))
Avatar
swiftNightly BOT 04-Oct-21 02:08 AM
denorun--allow-env=PATH--allow-net--allow-run=/usr/bin/env--quiet-
Avatar
norio_nomura 04-Oct-21 02:18 AM
Herokuから受け取った環境変数を標準入力として渡すshスクリプトでは、exec env -i で環境変数を消して、shプロセスをdenoプロセスへ置き換える形にしてる。
exec env -i PATH=${PATH} DENO_TLS_CA_STORE=system deno run ...
(edited)
これで procfs を経由したトークン取得の(知りうる範囲での)穴を塞げた。 (edited)
ここまで書けば、以前のきしかわさんのボットのハックとは関係無いだろう、という予想も より納得してもらえるかと。 (edited)
Avatar
norio_nomura 04-Oct-21 02:47 AM
他にも、ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてる故に起こせる挙動(ボットプロセスをkillするとか)もあるだろうけど、Herokuのコンテナを再起動すれば直る様なものは対策しないと思う。
Avatar
omochimetaru 04-Oct-21 02:48 AM
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてる
なるほど、出発点がそういう話なのか。
Avatar
norio_nomura 04-Oct-21 02:51 AM
いかにHerokuへお金を払わずに済ますかという縛りプレイ。
僕が提供してるボットの稼働には僕の人件費以外、使用量に応じたコストはかからないので、じゃんじゃん使ってください。 (edited)
😆 1
Avatar norio_nomura
ボットとSwiftコンパイラが同じコンテナ内の同じアカウントで動いてるのは、これはHerokuの制限なので今も変わらず。
Avatar
norio_nomura 04-Oct-21 02:58 AM
Herokuもお金を払えば、コンテナ分離構成で作れます。
一応今後の予定としては、たぶん、古いSwiftバージョンボットの非常駐化を優先します。
今まで僕のGmaiアドレスで<name>+...@gmail.com形式のエリアスを使って、Herokuのアカウントをボット毎に作ってきました。 (edited)
しかしswift55ボットのHerokuアカウントを作る際に、メールアドレスが弾かれる様になり作れなかったので、swift40ボットのHerokuアカウントを流用しました。
ボットを非常駐化すれば、Herokuアカウントを減らせるかなと。
Avatar
omochimetaru 04-Oct-21 03:09 AM
Heroku無料プラン縛りプレイ難しいw
Avatar
norio_nomura 04-Oct-21 03:10 AM
アカウントBANではなく、新規作成を弾いてくるのが巧妙ですw
まあ、Gmailエリアスではなく新規にGmailアカウントを作れば解決しそうですが、これも縛りの一環ということで。
HerokuのTOSを確認した限り、複数アカウント作成に関する制限は明文化されてないのですよね。
Avatar
koher 07-Oct-21 10:18 AM
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3
protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3
protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar
swift55 BOT 07-Oct-21 10:18 AM
exit status: 1 with stderr:
<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3
protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar
swift41 BOT 07-Oct-21 10:18 AM
exit status: 1 with stderr:
<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3
protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar
swift52 BOT 07-Oct-21 10:18 AM
exit status: 1 with stderr:
<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3
protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar
swift50 BOT 07-Oct-21 10:18 AM
exit status: 1 with stderr:
<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar koher
@swift-4.1.3 @swift-5.0.3 @swift-5.2.5 @swift-5.4.3 @swift-5.5.3
protocol P { var value: Int? { get } } struct S: P { let value: Int = 42 }
Avatar
swift54 BOT 07-Oct-21 10:18 AM
exit status: 1 with stderr:
<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:9: note: candidate has non-matching type 'Int' let value: Int = 42 ^ <stdin>:2:9: note: protocol requires property 'value' with type 'Int?'; do you want to add a stub? var value: Int? { get } ^
Avatar
koher 07-Oct-21 10:19 AM
これってだめなんだっけ?
@swift-5.5.3
class C { func foo() -> Int? { nil } } class SC: C { override func foo() -> Int { 42 } }
Avatar koher
@swift-5.5.3
class C { func foo() -> Int? { nil } } class SC: C { override func foo() -> Int { 42 } }
Avatar
swift55 BOT 07-Oct-21 10:21 AM
no output
Avatar
koher 07-Oct-21 10:21 AM
これはできるのか。
@swift-5.5.3
protocol P { func foo() -> Int? } struct S: P { func foo() -> Int { 42 } }
Avatar koher
@swift-5.5.3
protocol P { func foo() -> Int? } struct S: P { func foo() -> Int { 42 } }
Avatar
swift55 BOT 07-Oct-21 10:22 AM
exit status: 1 with stderr:
<stdin>:5:8: error: type 'S' does not conform to protocol 'P' struct S: P { ^ <stdin>:6:10: note: candidate has non-matching type '() -> Int' func foo() -> Int { 42 } ^ <stdin>:2:10: note: protocol requires function 'foo()' with type '() -> Int?'; do you want to add a stub? func foo() -> Int? ^
Avatar
koher 07-Oct-21 10:22 AM
こっちはダメ。
Avatar
tarunon 07-Oct-21 10:22 AM
readonly と readwriteは共変性と反変性がかわるので
set ableなのはダメですね
Avatar
koher 07-Oct-21 10:23 AM
{ get } なので readonly だし、 func の戻り値でもダメみたいですね。
Avatar
tarunon 07-Oct-21 11:03 AM
readonlyだった、失礼しました
確かOptionalのoverrideが許されてるのはclassだけで、
これもObjc互換のためだかで、2重オプショナルは壊れるとかそういう感じだったと思います (edited)
Avatar
koher 07-Oct-21 01:54 PM
なるほど。Optionalのサブタイピング、全般的に使えるのかと思ってました。
Avatar
tarunon 07-Oct-21 01:55 PM
あんまりあっちこっちで許しちゃうと破綻箇所が拡散しちゃいますからね
今のままで良いと考えています
Avatar
koher 07-Oct-21 11:43 PM
クラスの継承は許すけどプロトコルの適合は許さないというのは、すでにサブタイピングとして破綻してると思いますけどね〜。 @swift-5.5.3
class Animal {} class Cat: Animal {} protocol P { func animal() -> Animal } struct S { func animal() -> Cat { Cat() } }
Avatar koher
クラスの継承は許すけどプロトコルの適合は許さないというのは、すでにサブタイピングとして破綻してると思いますけどね〜。 @swift-5.5.3
class Animal {} class Cat: Animal {} protocol P { func animal() -> Animal } struct S { func animal() -> Cat { Cat() } }
Avatar
swift55 BOT 07-Oct-21 11:43 PM
no output
Avatar
koher 07-Oct-21 11:43 PM
↑とかもできるわけだし。 (edited)
やっぱり Foo | NilEither<Foo, Nil> を混ぜて扱うこと自体に無理がある・・・。 Codable と JSON の Foo?? とかも。色んなところで歪みが出るのは避けられなくて、できるだけ普段目に触れないところで出すようにしてるけど、普段目に見えないからこそ不意をつかれた感じになる。
一方で、 Obj-C 連携とか、普段の使い勝手(たとえば Optional に代入する度に .some を書くべきなのか)とかを考えると仕方ないよなぁ。仮に全部 Foo | Nil に寄せると IteratorProtocolnext が( ElementOptional のときに)表現できないとかそれはそれで問題があって、とはいえ Foo | NilEither<Foo, Nil> を適切に使い分けるのもハードルが高いし、どれを取っても一長一短。なので、 Swift は理論的なきれいさよりも実用上の使いやすさをとって、その分生じる歪みをできるだけ目立たないところで消化するという選択なんだろうなぁ。
Avatar
tarunon 08-Oct-21 01:21 AM
@swift-5.5.3
import Foundation @objc protocol P { func foo() -> NSObject? } class S: NSObject, P { func foo() -> NSObject { self } }
(edited)
Avatar tarunon
@swift-5.5.3
import Foundation @objc protocol P { func foo() -> NSObject? } class S: NSObject, P { func foo() -> NSObject { self } }
(edited)
Avatar
swift55 BOT 08-Oct-21 01:21 AM
exit status: 1 with stderr:
<stdin>:2:2: error: Objective-C interoperability is disabled @objc protocol P { ~^~~~~ <stdin>:6:7: error: type 'S' does not conform to protocol 'P' class S: NSObject, P { ^ <stdin>:7:10: note: candidate has non-matching type '() -> NSObject' func foo() -> NSObject { self } ^ <stdin>:3:10: note: protocol requires function 'foo()' with type '() -> NSObject?'; do you want to add a stub? func foo() -> NSObject? ^
(edited)
Avatar
tarunon 08-Oct-21 01:24 AM
@objc付けてもダメなのか
Avatar
koher 08-Oct-21 03:08 AM
Linux だから?
Avatar
omochimetaru 08-Oct-21 03:14 AM
たしかに @objc protocol だと準拠可能になったけど警告は出た
Avatar
tarunon 08-Oct-21 03:15 AM
良い塩梅な気がする
それならclassのoverrideも警告して良いんじゃないだろうかと感じるけど
Avatar
omochimetaru 08-Oct-21 03:23 AM
僕はオーバーライドのルールと、関数型の互換性のルールが一致してないのは変だと思う。
func trans(_ f: (Int) -> Int?) { _ = f(0) } func main() { func f(a: Int?) -> Int { a ?? 0 } // (Int?) -> Int is (Int) -> Int? trans(f) }
(edited)
Avatar
Iceman 08-Oct-21 03:35 AM
優先度が同じレベルのオーバーロードが存在した場合にどっちが適合すべきか区別つかないからこっちにも_disfavoredOverloadが必要になりそう
Avatar
omochimetaru 08-Oct-21 03:35 AM
それは通常のオーバロードと同じで、暗黙変換がなるべく少なくて済む方を選ぶ規則で良いと思う
Avatar
Iceman 08-Oct-21 03:38 AM
protocol P { func f(_ v: Int) -> Int? } class C: P { func f(_ v: Int?) -> Int? { 1 } func f(_ v: Int) -> Int { 2 } }
こういうの同じレベルになりませんか?
Avatar
tarunon 08-Oct-21 03:39 AM
それは別にOptionalに限った話ではない気がするけど
Avatar
omochimetaru 08-Oct-21 03:40 AM
↑これと同じ原理で、オーバーライドするメソッドを選択する。
Avatar
Iceman 08-Oct-21 03:43 AM
そういえばもう既に @_implements はあるか。
Avatar
Iceman 12-Oct-21 10:42 AM
@swift-5.5.3
@resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
Avatar Iceman
@swift-5.5.3
@resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
Avatar
swift55 BOT 12-Oct-21 10:42 AM
1
Avatar
Iceman 12-Oct-21 10:42 AM
これはできるのに
@swift-5.5.3
@resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } @_disfavoredOverload static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
Avatar Iceman
@swift-5.5.3
@resultBuilder enum MyBuilder { static func buildBlock<C>(_ c: C) -> C { c } @_disfavoredOverload static func buildBlock<C>(_ c: C) -> Int { 1 } } func f(@MyBuilder content: () -> Int) { print(content()) } f { "" }
Avatar
swift55 BOT 12-Oct-21 10:42 AM
exit status: 1 with stderr:
<stdin>:17:5: error: cannot convert value of type 'String' to closure result type 'Int' "" ^~
Avatar
Iceman 12-Oct-21 10:42 AM
これはできない
_disfavoredOverload をつけることで可能性がまるごと消えてしまった
Avatar
omochimetaru 12-Oct-21 10:51 AM
えーw なんで・・・
Avatar
Iceman 19-Oct-21 04:33 PM
@swift-5.5.3
import UIKit
Avatar Iceman
@swift-5.5.3
import UIKit
Avatar
swift55 BOT 19-Oct-21 04:33 PM
exit status: 1 with stderr:
<stdin>:1:8: error: no such module 'UIKit' import UIKit ^
Avatar
Iceman 22-Oct-21 09:04 AM
@swift-5.5.3
@propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { nonisolated var a: Int = 0 @Wrap nonisolated var i: Int = 0 nonisolated var u: Wrap = .init(wrappedValue: 0) nonisolated var e: Int { $i } nonisolated var o: Wrap { _i } }
(edited)
Avatar Iceman
@swift-5.5.3
@propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { nonisolated var a: Int = 0 @Wrap nonisolated var i: Int = 0 nonisolated var u: Wrap = .init(wrappedValue: 0) nonisolated var e: Int { $i } nonisolated var o: Wrap { _i } }
(edited)
Avatar
swift55 BOT 22-Oct-21 09:04 AM
exit status: 1 with stderr:
<stdin>:6:3: error: nonisolated' can not be applied to stored properties nonisolated var a: Int = 0 ^~~~~~~~~~~~ <stdin>:8:3: error: nonisolated' can not be applied to stored properties nonisolated var u: Wrap = .init(wrappedValue: 0) ^~~~~~~~~~~~ <stdin>:9:28: error: actor-isolated property '$i' can not be referenced from a non-isolated context nonisolated var e: Int { $i } ^ <stdin>:7:25: note: property declared here @Wrap nonisolated var i: Int = 0 ^ <stdin>:10:29: error: actor-isolated property '_i' can not be referenced from a non-isolated context nonisolated var o: Wrap { _i } ^ <stdin>:7:25: note: property declared here @Wrap nonisolated var i: Int = 0 ^
(edited)
Avatar
Iceman 22-Oct-21 09:11 AM
これ i だけOKなんだな
ほんまか?
@swift-5.5.3
@propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { @Wrap nonisolated var i: Int = 0 }
Avatar Iceman
@swift-5.5.3
@propertyWrapper struct Wrap { var wrappedValue: Int var projectedValue: Int = 0 } actor A { @Wrap nonisolated var i: Int = 0 }
Avatar
swift55 BOT 22-Oct-21 09:12 AM
no output
Avatar
Iceman 22-Oct-21 09:12 AM
ほんまや・・・
Avatar
omochimetaru 22-Oct-21 09:13 AM
あれ、それはなんでOKなんだ?
Avatar
norio_nomura 25-Oct-21 04:37 AM
@swift-5.5.3 -O @swift-5.5.3 -Onone
print(a) let a = 1 print(a)
😇 1
Avatar norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone
print(a) let a = 1 print(a)
Avatar
swift55 BOT 25-Oct-21 04:37 AM
swift -O -
1 1
Avatar norio_nomura
@swift-5.5.3 -O @swift-5.5.3 -Onone
print(a) let a = 1 print(a)
Avatar
swift55 BOT 25-Oct-21 04:37 AM
swift -Onone -
0 1
Avatar
tarunon 30-Oct-21 03:06 PM
@swift-5.5.3 @swift-nightly
_ = 1 as Sendable
Avatar tarunon
@swift-5.5.3 @swift-nightly
_ = 1 as Sendable
Avatar
swiftNightly BOT 30-Oct-21 03:06 PM
no output
Avatar tarunon
@swift-5.5.3 @swift-nightly
_ = 1 as Sendable
Avatar
swift55 BOT 30-Oct-21 03:06 PM
no output
Avatar
tarunon 30-Oct-21 03:06 PM
オッ治るのか
Avatar
Iceman 30-Oct-21 05:00 PM
@swift-nightly
protocol P {} extension Int: P {} func f() -> [some P] { [1, 2] } print(f())
(edited)
Avatar Iceman
@swift-nightly
protocol P {} extension Int: P {} func f() -> [some P] { [1, 2] } print(f())
(edited)
Avatar
swiftNightly BOT 30-Oct-21 05:00 PM
exit status: 1 with stderr:
<stdin>:3:13: error: 'opaque' types cannot be nested inside other types; structural 'opaque' types are an experimental feature func f() -> [some P] { [1, 2] } ^
(edited)
Avatar
Iceman 31-Oct-21 04:43 PM
@swift-5.5.3 @swift-5.4.3
import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar Iceman
@swift-5.5.3 @swift-5.4.3
import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar
swift54 BOT 31-Oct-21 04:43 PM
() -> () () throws -> ()
Avatar Iceman
@swift-5.5.3 @swift-5.4.3
import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar
swift55 BOT 31-Oct-21 04:43 PM
() -> () () throws -> ()
Avatar
Iceman 31-Oct-21 04:44 PM
@swift-5.0.3
import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar Iceman
@swift-5.0.3
import XCTest let c1 = { XCTAssertNoThrow(1) } let c2 = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c1)) print(type(of: c2))
Avatar
swift50 BOT 31-Oct-21 04:44 PM
() -> () () throws -> ()
Avatar
Iceman 31-Oct-21 04:45 PM
autoclosureにthrows吸われると思ってたけど吸われないのか
Avatar
Iceman 04-Nov-21 06:22 AM
@swift-5.5.3
import XCTest let c3: () -> () = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } func c4() { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c3)) print(type(of: c4))
Avatar Iceman
@swift-5.5.3
import XCTest let c3: () -> () = { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } func c4() { XCTAssertNoThrow(try Result<Int, Error>.success(1).get()) } print(type(of: c3)) print(type(of: c4))
Avatar
swift55 BOT 04-Nov-21 06:22 AM
exit status: 1 with stderr:
<stdin>:3:20: error: invalid conversion from throwing function of type '() throws -> ()' to non-throwing function type '() -> ()' let c3: () -> () = { ^
Avatar
Iceman 04-Nov-21 06:23 AM
funcのときはautoclosureにtry吸われるけど、クロージャとして定義するときは吸われないというものだった
Avatar
Iceman 09-Nov-21 10:42 AM
@swift-5.5.3
func f() { print(nanika) } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
Avatar Iceman
@swift-5.5.3
func f() { print(nanika) } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
Avatar
swift55 BOT 09-Nov-21 10:42 AM
nanika is initialized!
Avatar
Iceman 09-Nov-21 10:43 AM
@swift-5.5.3
func f() { let v = nanika if v.isEmpty { print("nanika is empty") } else { print(v) } } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
Avatar Iceman
@swift-5.5.3
func f() { let v = nanika if v.isEmpty { print("nanika is empty") } else { print(v) } } f() let nanika: String = { print("nanika is initialized!") return "nanika" }()
Avatar
swift55 BOT 09-Nov-21 10:43 AM
nanika is empty nanika is initialized!
Avatar
kateinoigakukun 09-Nov-21 10:44 AM
何かが消滅した
Avatar
Iceman 09-Nov-21 10:44 AM
これmacosだとクラッシュするんですよ
Avatar
omochimetaru 09-Nov-21 10:46 AM
うちのmacだと動いたけど、emptyが先に出るのはどっちにしても変だな
Avatar
Iceman 09-Nov-21 10:47 AM
あれ、実行できてますね。僕がplaygroundでやってるからかも
Avatar
kateinoigakukun 09-Nov-21 10:48 AM
@swift-nightly
func f() { nanika.withCString { ptr in print(ptr.pointee) } } f() let nanika: String = { return "nanika" }()
(edited)
Avatar kateinoigakukun
@swift-nightly
func f() { nanika.withCString { ptr in print(ptr.pointee) } } f() let nanika: String = { return "nanika" }()
(edited)
Avatar
swiftNightly BOT 09-Nov-21 10:48 AM
exit status: 139 with stderr:
Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM bfd3cb18089d333, Swift 367b4c1355d9269) 2. Compiling with the current language version 3. While running user code "<stdin>" Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5f5aee3] /usr/bin/swift-frontend[0x5f58a8e] /usr/bin/swift-frontend[0x5f5b276] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fcd67aec980] /usr/lib/swift/linux/libswiftCore.so($ss13_StringObjectV18getSharedUTF8StartSPys5UInt8VGyF+0xd)[0x7fcd5ed2f22d]
Avatar
kateinoigakukun 09-Nov-21 10:54 AM
@swift-nightly
print(nanika) let nanika: String = { return "nanika" }()
Avatar kateinoigakukun
@swift-nightly
print(nanika) let nanika: String = { return "nanika" }()
Avatar
swiftNightly BOT 09-Nov-21 10:54 AM
Avatar
kateinoigakukun 09-Nov-21 10:54 AM
@swift-nightly
let nanika: String = { return "nanika" }() print(nanika)
Avatar kateinoigakukun
@swift-nightly
let nanika: String = { return "nanika" }() print(nanika)
Avatar
swiftNightly BOT 09-Nov-21 10:54 AM
nanika
Avatar
kateinoigakukun 09-Nov-21 10:56 AM
nanikaの宣言の位置によってnanikaの初期化処理の配置がIRレベルで変わるが、Swiftレベルではどこでも触れるので、初期化前に触って死ぬらしい
Avatar
Kishikawa Katsumi 09-Nov-21 10:56 AM
トップレベルのコードかどうかは関係ある?
Avatar
kateinoigakukun 09-Nov-21 10:56 AM
ありますね
これはコンパイル通らないので初期化前の使用が防げる
func main() { print(nanika) let nanika: String = { return "nanika" }() }
Avatar kateinoigakukun
nanikaの宣言の位置によってnanikaの初期化処理の配置がIRレベルで変わるが、Swiftレベルではどこでも触れるので、初期化前に触って死ぬらしい
Avatar
omochimetaru 09-Nov-21 10:57 AM
グローバル変数に触る時って必ず初期化関数を介すると思ったが、トップレベルだとそうではないのか
Avatar
kateinoigakukun 09-Nov-21 10:58 AM
たぶんクロージャで初期化してるのが関係してる気がする
Avatar
Kishikawa Katsumi 09-Nov-21 10:58 AM
この現象が触れるのってスクリプトとしてSwiftを実行する場合だけ?
Avatar
kateinoigakukun 09-Nov-21 10:59 AM
普通にコンパイルしても再現するんですよ
Avatar
Kishikawa Katsumi 09-Nov-21 11:01 AM
そうなんだ。
Avatar
Iceman 09-Nov-21 11:04 AM
これfの実装が別ファイルだとうっかり起こりうるかもなと。
Avatar
kateinoigakukun 09-Nov-21 11:10 AM
あー、きしかわさんの「スクリプトとして」の意味が分かった。確かにライブラリとしてパースするとちゃんと初期化関数はさまるので
Avatar
Kishikawa Katsumi 09-Nov-21 11:10 AM
そうそう。as libraryみたいなオプション。
直接実行しない場合はそうするんじゃなかったっけ。
Avatar
kateinoigakukun 09-Nov-21 11:10 AM
普通にアプリを書いてて -parse-as-library 付けてれば大丈夫ですね
ですね
Avatar
rintaro 10-Nov-21 06:58 AM
ちょうど最近トップレベルの変数宣言についてアクティブな議論がありました。 https://forums.swift.org/t/on-the-behavior-of-variables-in-top-level-code/52230
The variables in top-level code behave weirdly. They are declared in the global scope, but are initialized serially, like local variables in a normal function. This allows some interesting pieces of code to compile, such as: print(x) var x = 32 This program will print 0. The basic value types are automatically initialized, so they have a value...
👀 1
Avatar
tarunon 10-Nov-21 10:45 AM
@swift-5.5.3
print(1 / 0)
Avatar tarunon
@swift-5.5.3
print(1 / 0)
Avatar
swift55 BOT 10-Nov-21 10:45 AM
exit status: 1 with stderr:
<stdin>:1:9: error: division by zero print(1 / 0) ^
Avatar
tarunon 10-Nov-21 10:45 AM
@swift-5.5.3
print(1.0 / 0.0)
Avatar tarunon
@swift-5.5.3
print(1.0 / 0.0)
Avatar
swift55 BOT 10-Nov-21 10:45 AM
inf
Avatar
Ensan 10-Nov-21 12:22 PM
@swift-nightly -Xfrontend -enable-experimental-structural-opaque-types
let t: (some Numeric, some Numeric) = (0, 0) print(t)
(edited)
Avatar Ensan
@swift-nightly -Xfrontend -enable-experimental-structural-opaque-types
let t: (some Numeric, some Numeric) = (0, 0) print(t)
(edited)
Avatar
swiftNightly BOT 10-Nov-21 12:22 PM
exit status: 1 with stderr:
<stdin>:1:8: error: '(some Numeric, some Numeric)' contains multiple 'opaque' types, but only one 'opaque' type is supported let t: (some Numeric, some Numeric) = (0, 0) ^
(edited)
Avatar
kateinoigakukun 10-Nov-21 12:26 PM
@swift-nightly -Xfrontend -typecheck -Xfrontend -enable-experimental-structural-opaque-types
protocol P {} extension Int: P {} let t: (Int, some P) = (0, 0)
(edited)
Avatar kateinoigakukun
@swift-nightly -Xfrontend -typecheck -Xfrontend -enable-experimental-structural-opaque-types
protocol P {} extension Int: P {} let t: (Int, some P) = (0, 0)
(edited)
Avatar
swiftNightly BOT 10-Nov-21 12:26 PM
no output (edited)
Avatar
kateinoigakukun 10-Nov-21 12:27 PM
こんなオプションあったんですね
なんか動いてないけど -typecheckしかまだだめっぽい (edited)
Avatar
Ensan 10-Nov-21 12:28 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0328-structural-opaque-result-types.md at main · apple/swift-evolution
👀 1
Avatar
kateinoigakukun 10-Nov-21 12:31 PM
Hello, Swift community. The review of SE-0328: Structural opaque result types begins now and runs through November 11, 2021. Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager. If you do email...
Avatar
tarunon 10-Nov-21 12:32 PM
はやくきてくれ!
Avatar
koher 13-Nov-21 12:53 AM
@swift-5.5.3 -Xfrontend -warn-concurrency
actor SendableExperiment { private var int: Int = 0 private var user2: User2 = .init() private var user3: User3 = .init() private var user4: User4 = .init() private var user5: User5 = .init() func increment() -> Int { int += 1 return int } func incrementAge2() -> User2 { user2.age += 1 return user2 } func incrementAge3() -> User3 { user3.age += 1 return user3 } func incrementAge4() -> User4 { user4.age += 1 return user4 } func incrementAge5() -> User5 { // user5.age += 1 return user5 } } struct User2 { let name: String = "Foo" var age: Int = 42 } public struct User3 { public let name: String = "Foo" public var age: Int = 42 } final class User4 { let name: String = "Foo" var age: Int = 42 } final class User5 { let name: String = "Foo" let age: Int = 42 }
Avatar koher
@swift-5.5.3 -Xfrontend -warn-concurrency
actor SendableExperiment { private var int: Int = 0 private var user2: User2 = .init() private var user3: User3 = .init() private var user4: User4 = .init() private var user5: User5 = .init() func increment() -> Int { int += 1 return int } func incrementAge2() -> User2 { user2.age += 1 return user2 } func incrementAge3() -> User3 { user3.age += 1 return user3 } func incrementAge4() -> User4 { user4.age += 1 return user4 } func incrementAge5() -> User5 { // user5.age += 1 return user5 } } struct User2 { let name: String = "Foo" var age: Int = 42 } public struct User3 { public let name: String = "Foo" public var age: Int = 42 } final class User4 { let name: String = "Foo" var age: Int = 42 } final class User5 { let name: String = "Foo" let age: Int = 42 }
Avatar
swift55 BOT 13-Nov-21 12:53 AM
no output
Avatar
koher 13-Nov-21 12:53 AM
3と4通るんだっけ??
Avatar
Iceman 19-Nov-21 03:19 AM
@swift-nightly @swift-5.5.3 -warn-concurrency
@MainActor protocol P { } struct S: P {} Task { await MainActor.run { let p: P = S() let optionalP: P! = nil let s: S = S() Task { print(String(describing: p)) print(String(describing: optionalP)) print(String(describing: s)) } } }
(edited)
Avatar Iceman
@swift-nightly @swift-5.5.3 -warn-concurrency
@MainActor protocol P { } struct S: P {} Task { await MainActor.run { let p: P = S() let optionalP: P! = nil let s: S = S() Task { print(String(describing: p)) print(String(describing: optionalP)) print(String(describing: s)) } } }
(edited)
Avatar
swiftNightly BOT 19-Nov-21 03:19 AM
stderr:
<stdin>:11:32: warning: cannot use let 'p' with a non-sendable type 'P' from concurrently-executed code print(String(describing: p)) ^ <stdin>:1:21: note: protocol 'P' does not conform to the 'Sendable' protocol @MainActor protocol P { } ^ <stdin>:12:32: warning: cannot use let 'optionalP' with a non-sendable type 'P?' from concurrently-executed code print(String(describing: optionalP)) ^ <stdin>:1:21: note: protocol 'P' does not conform to the 'Sendable' protocol @MainActor protocol P { } ^
(edited)
Avatar Iceman
@swift-nightly @swift-5.5.3 -warn-concurrency
@MainActor protocol P { } struct S: P {} Task { await MainActor.run { let p: P = S() let optionalP: P! = nil let s: S = S() Task { print(String(describing: p)) print(String(describing: optionalP)) print(String(describing: s)) } } }
(edited)
Avatar
swift55 BOT 19-Nov-21 03:19 AM
stderr:
<stdin>:11:32: warning: cannot use let 'p' with a non-sendable type 'P' from concurrently-executed code print(String(describing: p)) ^ <stdin>:12:32: warning: cannot use let 'optionalP' with a non-sendable type 'P?' from concurrently-executed code print(String(describing: optionalP)) ^
(edited)
Avatar
Iceman 29-Nov-21 06:21 AM
@swift-5.5.3 @swift-5.4.3 --version
Avatar Iceman
@swift-5.5.3 @swift-5.4.3 --version
Avatar
swift54 BOT 29-Nov-21 06:21 AM
Swift version 5.4.3 (swift-5.4.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar Iceman
@swift-5.5.3 @swift-5.4.3 --version
Avatar
swift55 BOT 29-Nov-21 06:21 AM
Swift version 5.5-dev (LLVM c315411fac10439, Swift 424bc4056fc81c2) Target: x86_64-unknown-linux-gnu
Avatar
Iceman 29-Nov-21 06:22 AM
@swift-5.1.5 --version
Avatar Iceman
@swift-5.1.5 --version
Avatar
swift51 BOT 29-Nov-21 06:22 AM
Swift version 5.1.5 (swift-5.1.5-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Iceman 29-Nov-21 06:53 AM
@swift-4.1.3 --version
Avatar Iceman
@swift-4.1.3 --version
Avatar
swift41 BOT 29-Nov-21 06:53 AM
Swift version 4.1.3 (swift-4.1.3-RELEASE) Target: x86_64-unknown-linux-gnu
Avatar
Iceman 30-Nov-21 03:34 AM
@swift-nightly -warn-concurrency
var const: Int { 42 } let const2: Int = 42 actor A { init() { _ = const _ = const2 } }
Avatar Iceman
@swift-nightly -warn-concurrency
var const: Int { 42 } let const2: Int = 42 actor A { init() { _ = const _ = const2 } }
Avatar
swiftNightly BOT 30-Nov-21 03:34 AM
stderr:
<stdin>:6:9: warning: reference to var 'const' is not concurrency-safe because it involves shared mutable state _ = const ^ <stdin>:1:5: note: var declared here var const: Int { 42 } ^
Avatar
kateinoigakukun 30-Nov-21 03:36 AM
@swift-nightly -warn-concurrency
func const() -> Int { 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } }
(edited)
Avatar kateinoigakukun
@swift-nightly -warn-concurrency
func const() -> Int { 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } }
(edited)
Avatar
swiftNightly BOT 30-Nov-21 03:36 AM
no output (edited)
Avatar
Iceman 30-Nov-21 03:37 AM
あれ、関数はいいんだw
グローバル変数をキャプチャする可能性を捨てられないような気がするけど
Avatar
kateinoigakukun 30-Nov-21 03:38 AM
よくわからないですねw
@swift-nightly -warn-concurrency
var mutableG = 0 func const() -> Int { mutableG = 1 return 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } }
Avatar kateinoigakukun
@swift-nightly -warn-concurrency
var mutableG = 0 func const() -> Int { mutableG = 1 return 42 } let const2: Int = 42 actor A { init() { _ = const() _ = const2 } }
Avatar
swiftNightly BOT 30-Nov-21 03:38 AM
stderr:
<stdin>:3:3: warning: reference to var 'mutableG' is not concurrency-safe because it involves shared mutable state mutableG = 1 ^ <stdin>:1:5: note: var declared here var mutableG = 0 ^
Avatar
kateinoigakukun 30-Nov-21 03:39 AM
なるほど?
Avatar
Iceman 30-Nov-21 03:39 AM
const() がactor contextを持っているかのような警告だ
@swift-nightly -warn-concurrency
var mutableG = 0 func const() -> Int { mutableG = 1 return 42 }
Avatar Iceman
@swift-nightly -warn-concurrency
var mutableG = 0 func const() -> Int { mutableG = 1 return 42 }
Avatar
swiftNightly BOT 30-Nov-21 03:40 AM
stderr:
<stdin>:3:3: warning: reference to var 'mutableG' is not concurrency-safe because it involves shared mutable state mutableG = 1 ^ <stdin>:1:5: note: var declared here var mutableG = 0 ^
Avatar
Iceman 30-Nov-21 03:40 AM
へぇ〜グローバル関数全体がconcurrency-safeか検査するようになってるのかな
Avatar
kateinoigakukun 30-Nov-21 03:41 AM
ぽいですね
Avatar
omochimetaru 30-Nov-21 03:50 AM
@kateinoigakukun このへんの並行安全性ってRustだとどうなってるの?RustにもSendableの概念あるよね
Avatar
kateinoigakukun 30-Nov-21 04:06 AM
グローバルなmutable変数へのアクセスは一律unsafeになっていてMutexを使わない限り非安全な操作として扱われますね。ここはSend traitを実装していたとしても変わらないです
Avatar
omochimetaru 30-Nov-21 04:07 AM
なるほど。じゃあSwiftのほうがより強力な並行安全を目指してるのか。
Rustより安全な部分が出てきうるのはすごいな
Avatar
kateinoigakukun 30-Nov-21 04:09 AM
isolation周りはそうですねえ
Avatar
Iceman 30-Nov-21 04:59 AM
@swift-5.5.3
import Foundation let json = """ { "foo": "{\"key\": \"value\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
(edited)
Avatar Iceman
@swift-5.5.3
import Foundation let json = """ { "foo": "{\"key\": \"value\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
(edited)
Avatar
swift55 BOT 30-Nov-21 04:59 AM
exit status: 132 with stderr:
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Foundation.JSONError.unexpectedCharacter(ascii: 107, characterIndex: 16)))) Current stack trace: 0 libswiftCore.so 0x00007f8a2e843cd0 swift_reportError + 50 1 libswiftCore.so 0x00007f8a2e8bc2a0 _swift_stdlib_reportFatalErrorInFile + 109 2 libswiftCore.so 0x00007f8a2e5c95a2 <unavailable> + 1414562 3 libswiftCore.so 0x00007f8a2e5c92cb <unavailable> + 1413835 4 libswiftCore.so 0x00007f8a2e5c7fb0 _assertionFailure(_:_:file:line:flags:) + 447 5 libswiftCore.so 0x00007f8a2e628d10 swift_errorInMain + 731 7 swift-frontend 0x00000000006e228a <unavailable> + 3023498 8 swift-frontend 0x00000000005ba271 <unavailable> + 1811057 9 swift-frontend 0x000000000056ddc3 <unavailable> + 1498563 10 swift-frontend 0x000000000056d5f7 <unavailable> + 1496567 11 swift-frontend 0x000000000056135e <unavailable> + 1446750 12 swift-frontend 0x00000000004b0646 <unavailable> + 722502 13 libc.so.6 0x00007f8a321f6b10 __libc_start_main + 231 14 swift-frontend 0x00000000004b027a <unavailable> + 721530 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.5-dev (LLVM c315411fac10439, Swift 424bc4056fc81c2) 2. 3. While running user code "<stdin>" Stack dump wit
(edited)
Avatar
Iceman 30-Nov-21 05:11 AM
エスケープされたJSON文字列をデコードする方法ないのかな?
あれ、これ文字列リテラルの書き方のほうがまずいのか
@swift-5.5.3
import Foundation let json = """ { "foo": "{\\"key\\": \\"value\\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Avatar Iceman
@swift-5.5.3
import Foundation let json = """ { "foo": "{\\"key\\": \\"value\\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Avatar
swift55 BOT 30-Nov-21 05:13 AM
Body(foo: "{\"key\": \"value\"}")
Avatar
omochimetaru 30-Nov-21 07:03 AM
ややこしい
Avatar
rintaro 01-Dec-21 12:06 AM
そのための SE-0200 なので使ってあげて
import Foundation let json = #"{ "foo": "{\"key\": \"value\"}" }"#.data(using: .utf8)! struct Body: Codable { var foo: String } let decoded = try JSONDecoder().decode(Body.self, from: json) print(decoded)
Avatar
omochimetaru 01-Dec-21 03:26 AM
@swift-5.5.3
import Foundation let json = #""" { "foo": "{\"key\": \"value\"}" } """#.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Avatar omochimetaru
@swift-5.5.3
import Foundation let json = #""" { "foo": "{\"key\": \"value\"}" } """#.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded)
Avatar
swift55 BOT 01-Dec-21 03:26 AM
Body(foo: "{\"key\": \"value\"}")
Avatar
omochimetaru 01-Dec-21 03:27 AM
お。複数行リテラルのシャープ付きモードもあるんだ。
Avatar
ProfFan 06-Dec-21 12:34 AM
@swift-nightly
import Differentiation @differentiable func test(x: Float) -> Float { x*x }
Avatar ProfFan
@swift-nightly
import Differentiation @differentiable func test(x: Float) -> Float { x*x }
Avatar
swiftNightly BOT 06-Dec-21 12:34 AM
exit status: 1 with stderr:
<stdin>:3:16: warning: '@differentiable' has been renamed to '@differentiable(reverse)' and will be removed in the next release @differentiable ^ (reverse) <stdin>:1:8: error: no such module 'Differentiation' import Differentiation ^
Avatar
Ensan 08-Dec-21 08:44 AM
@swift-nightly
func twoOpaqueTypes() -> (some Numeric, some Numeric) { return (1, 2) }
(edited)
Avatar Ensan
@swift-nightly
func twoOpaqueTypes() -> (some Numeric, some Numeric) { return (1, 2) }
(edited)
Avatar
swiftNightly BOT 08-Dec-21 08:44 AM
exit status: 1 with stderr:
<stdin>:1:26: error: '(some Numeric, some Numeric)' contains multiple 'opaque' types, but only one 'opaque' type is supported func twoOpaqueTypes() -> (some Numeric, some Numeric) { return (1, 2) } ^
(edited)
Avatar
nanasi 08-Dec-21 11:32 AM
@swift-nightly
struct Links { var `self`: String init(`self`: String) { self.`self` = `self` } } var links = Links(self: "foo/bar") print(links.`self`)
(edited)
Avatar nanasi
@swift-nightly
struct Links { var `self`: String init(`self`: String) { self.`self` = `self` } } var links = Links(self: "foo/bar") print(links.`self`)
(edited)
Avatar
swiftNightly BOT 08-Dec-21 11:32 AM
exit status: 1 with stderr:
<stdin>:5:14: error: value of type 'String' has no member 'self' self.`self` = `self` ~~~~ ^~~~~~
(edited)
Avatar
nanasi 15-Dec-21 05:21 AM
@swift-nightly
let dict: [_: String] = [0: "zero", 1: "one", 2: "two"]
Avatar nanasi
@swift-nightly
let dict: [_: String] = [0: "zero", 1: "one", 2: "two"]
Avatar
swiftNightly BOT 15-Dec-21 05:21 AM
no output
Avatar
Iceman 15-Dec-21 06:52 AM
@swift-5.5.3 -warn-concurrency
@MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() } } }
(edited)
Avatar Iceman
@swift-5.5.3 -warn-concurrency
@MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() } } }
(edited)
Avatar
swift55 BOT 15-Dec-21 06:52 AM
stderr:
<stdin>:21:7: warning: cannot use let 'xvc' with a non-sendable type 'XViewController' from concurrently-executed code xvc.viewDidAppear() ^
(edited)
Avatar
Iceman 15-Dec-21 06:54 AM
なんか変なケースがあった気がするけど忘れてしまった
お、XViewControllerがnon-sendableだ
MainActorだと認識してるのにSendableではない
Avatar
kateinoigakukun 15-Dec-21 06:57 AM
XViewController自体はMainActorで保護されていなくて、ViewController から派生して来たものだけが保護されてるんじゃなかったでしたっけ?
Avatar
Iceman 15-Dec-21 06:58 AM
@swift-5.5.3 -warn-concurrency
@MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } func viewDidAppear2() {} } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } }
Avatar Iceman
@swift-5.5.3 -warn-concurrency
@MainActor class ViewController { func viewDidAppear() {} } class XViewController: ViewController { override func viewDidAppear() { } func viewDidAppear2() {} } @MainActor protocol StateProtocol { } class State: StateProtocol { func f() async { let vc = ViewController() let xvc = XViewController() Task { vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } vc.viewDidAppear() xvc.viewDidAppear() xvc.viewDidAppear2() } }
Avatar
swift55 BOT 15-Dec-21 06:58 AM
stderr:
<stdin>:22:7: warning: cannot use let 'xvc' with a non-sendable type 'XViewController' from concurrently-executed code xvc.viewDidAppear() ^ <stdin>:23:7: warning: cannot use let 'xvc' with a non-sendable type 'XViewController' from concurrently-executed code xvc.viewDidAppear2() ^
Avatar kateinoigakukun
XViewController自体はMainActorで保護されていなくて、ViewController から派生して来たものだけが保護されてるんじゃなかったでしたっけ?
Avatar
Iceman 15-Dec-21 06:59 AM
「ViewController から派生して来たもの」ってどういうくくりでしょうか?
Avatar
kateinoigakukun 15-Dec-21 07:00 AM
↑の例だと viewDidAppear だけですかね
Avatar
Iceman 15-Dec-21 07:02 AM
あとから追加した viewDidAppear2 もMainActorとして認識されてそうと思って↑の例を書きましたが、よく考えたら XVC は何のglobalActorにも保護されてないからただ普通に呼んでるだけでした・・・
Avatar
Iceman 15-Dec-21 11:08 AM
@swift-5.5.3 test
import XCTest class T: XCTestCase { func testA() async throws {} }
Avatar Iceman
@swift-5.5.3 test
import XCTest class T: XCTestCase { func testA() async throws {} }
Avatar
swift55 BOT 15-Dec-21 11:08 AM
exit status: 64 with stderr:
error: Unexpected argument '-' Usage: swift test <options> See 'test -help' for more information.
Avatar
norio_nomura 15-Dec-21 02:26 PM
@swift-5.5.3
import XCTest class T: XCTestCase { func testA() async throws {} static let allTests = [("testA", asyncTest(testA))] } XCTMain([testCase(T.allTests)])
(edited)
Avatar norio_nomura
@swift-5.5.3
import XCTest class T: XCTestCase { func testA() async throws {} static let allTests = [("testA", asyncTest(testA))] } XCTMain([testCase(T.allTests)])
(edited)
Avatar
swift55 BOT 15-Dec-21 02:26 PM
Test Suite 'All tests' started at 2021-12-15 14:28:43.336 Test Suite 'bin.xctest' started at 2021-12-15 14:28:43.338 Test Suite 'T' started at 2021-12-15 14:28:43.338 Test Case 'T.testA' started at 2021-12-15 14:28:43.338 Test Case 'T.testA' passed (0.002 seconds) Test Suite 'T' passed at 2021-12-15 14:28:43.340 Executed 1 test, with 0 failures (0 unexpected) in 0.002 (0.002) seconds Test Suite 'bin.xctest' passed at 2021-12-15 14:28:43.340 Executed 1 test, with 0 failures (0 unexpected) in 0.002 (0.002) seconds Test Suite 'All tests' passed at 2021-12-15 14:28:43.340 Executed 1 test, with 0 failures (0 unexpected) in 0.002 (0.002) seconds
(edited)
Avatar
Iceman 20-Dec-21 09:39 AM
@swift-5.5.3 -warn-concurrency
func f2() async -> Int { 42 } class C {} struct S { let c = C() var value = 0 func f() async { let _ = await f2() print(value) } }
(edited)
Avatar Iceman
@swift-5.5.3 -warn-concurrency
func f2() async -> Int { 42 } class C {} struct S { let c = C() var value = 0 func f() async { let _ = await f2() print(value) } }
(edited)
Avatar
swift55 BOT 20-Dec-21 09:39 AM
no output (edited)
Avatar
Iceman 20-Dec-21 09:44 AM
SはSendableじゃないのにawaitをまたげるのはいいんだっけ?
暗黙のglobalActorがSについててf のスコープ内では保護されてるのかな
Avatar
koher 20-Dec-21 09:49 AM
await はまたげるんじゃないですか?
Actor boundary を越えられないのと、 @Sendable クロージャがキャプチャできない。
Avatar
Iceman 20-Dec-21 10:09 AM
@swift-5.5.3 -warn-concurrency
import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1)
(edited)
Avatar Iceman
@swift-5.5.3 -warn-concurrency
import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1)
(edited)
Avatar
swift55 BOT 20-Dec-21 10:09 AM
1 2 3 4 5 6 7 8 9 10
(edited)
Avatar
Iceman 20-Dec-21 10:10 AM
@swift-5.5.3 -warn-concurrency
import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { // let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1)
(edited)
Avatar Iceman
@swift-5.5.3 -warn-concurrency
import Foundation func f2() async -> Int { 42 } class Nanika { var value = 0 func f() async { // let _ = await f2() value += 1 print(value) } } let nanika = Nanika() for _ in 0..<10 { Task.detached { await nanika.f() } } sleep(1)
(edited)
Avatar
swift55 BOT 20-Dec-21 10:10 AM
2 1 4 5 6 7 8 9 3 10
(edited)
Avatar
Iceman 20-Dec-21 10:12 AM
await 以降の処理がグローバルなコンテキストで律速してる?
暗黙globalActorのQueueが2個のときと1個のときがあって2個のときはバラけるな (edited)
2個以上あるときは同じ Nanika に対して並列に f を呼び出すと壊れるけど、そもそも呼び出しの時点で何も安全性が保証されてないのでそこを保護してもしょうがないのか
Avatar
kateinoigakukun 22-Dec-21 04:49 AM
@swift-nightly @swift-5.5.3
struct MyError: Error {} func throwError() async throws -> Int { throw MyError() } func main() async { async let v = try throwError() _ = try! await v }
(edited)
Avatar kateinoigakukun
@swift-nightly @swift-5.5.3
struct MyError: Error {} func throwError() async throws -> Int { throw MyError() } func main() async { async let v = try throwError() _ = try! await v }
(edited)
Avatar
swiftNightly BOT 22-Dec-21 04:49 AM
no output (edited)
Avatar kateinoigakukun
@swift-nightly @swift-5.5.3
struct MyError: Error {} func throwError() async throws -> Int { throw MyError() } func main() async { async let v = try throwError() _ = try! await v }
(edited)
Avatar
swift55 BOT 22-Dec-21 04:50 AM
no output (edited)
Avatar
kateinoigakukun 22-Dec-21 04:52 AM
try throwError() の tryは無意味だけどワーニングが出ない
Avatar
Iceman 24-Dec-21 08:58 AM
@swift-5.5.3
import Foundation print("Swift, Error".components(separatedBy: .init(charactersIn: ","))) print("Swift, Error".split(separator: ","))
(edited)
Avatar Iceman
@swift-5.5.3
import Foundation print("Swift, Error".components(separatedBy: .init(charactersIn: ","))) print("Swift, Error".split(separator: ","))
(edited)
Avatar
swift55 BOT 24-Dec-21 08:58 AM
["Swift", " Error"] ["Swift", " Error"]
(edited)
Avatar
Iceman 24-Dec-21 09:42 AM
@swift-nightly @swift-5.5.3 -warn-concurrency
import Foundation @MainActor struct Button { var action: () -> () init(_ action: @escaping () -> ()) { self.action = action } func work() { let action = action DispatchQueue.global().async { action() } } } @MainActor struct MyView { var body: some Any { Button { f() } } func f() { print("Thread.isMainThread", Thread.isMainThread) print(Thread.current) } } Task { await MainActor.run { let view = MyView() let button = view.body as! Button button.work() } } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) print("end")
(edited)
Avatar Iceman
@swift-nightly @swift-5.5.3 -warn-concurrency
import Foundation @MainActor struct Button { var action: () -> () init(_ action: @escaping () -> ()) { self.action = action } func work() { let action = action DispatchQueue.global().async { action() } } } @MainActor struct MyView { var body: some Any { Button { f() } } func f() { print("Thread.isMainThread", Thread.isMainThread) print(Thread.current) } } Task { await MainActor.run { let view = MyView() let button = view.body as! Button button.work() } } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) print("end")
(edited)
Avatar
swiftNightly BOT 24-Dec-21 09:42 AM
Thread.isMainThread false <Thread: 0x00007fb86c002140> end
stderr:
<stdin>:11:13: warning: cannot use let 'action' with a non-sendable type '() -> ()' from concurrently-executed code action() ^ <stdin>:11:13: note: a function type must be marked '@Sendable' to conform to 'Sendable' action() ^
(edited)
Avatar Iceman
@swift-nightly @swift-5.5.3 -warn-concurrency
import Foundation @MainActor struct Button { var action: () -> () init(_ action: @escaping () -> ()) { self.action = action } func work() { let action = action DispatchQueue.global().async { action() } } } @MainActor struct MyView { var body: some Any { Button { f() } } func f() { print("Thread.isMainThread", Thread.isMainThread) print(Thread.current) } } Task { await MainActor.run { let view = MyView() let button = view.body as! Button button.work() } } RunLoop.main.run(until: Date().addingTimeInterval(0.3)) print("end")
(edited)
Avatar
swift55 BOT 24-Dec-21 09:43 AM
Thread.isMainThread false <Thread: 0x00007fec20002130> end
stderr:
<stdin>:11:13: warning: cannot use let 'action' with a non-sendable type '() -> ()' from concurrently-executed code action() ^
(edited)
Avatar
Iceman 24-Dec-21 09:48 AM
@MainActorf がメインスレッド以外から呼ばれてるけど、一応Sendableの警告は出てるのでセーフか
Avatar
Iceman 29-Dec-21 11:29 AM
@swift-5.5.3 -warn-concurrency
@dynamicMemberLookup struct Box<Value> { var value: Value subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, T>) -> T { get { value[keyPath: keyPath] } set { value[keyPath: keyPath] = newValue } } } struct Foo { var count: Int = 0 } let boxed = Box(value: Foo()) print(boxed.count) let boxedBoxed = Box(value: boxed) print(boxedBoxed.count) print(boxedBoxed[dynamicMember: \.[dynamicMember: \Foo.count]])
(edited)
Avatar Iceman
@swift-5.5.3 -warn-concurrency
@dynamicMemberLookup struct Box<Value> { var value: Value subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, T>) -> T { get { value[keyPath: keyPath] } set { value[keyPath: keyPath] = newValue } } } struct Foo { var count: Int = 0 } let boxed = Box(value: Foo()) print(boxed.count) let boxedBoxed = Box(value: boxed) print(boxedBoxed.count) print(boxedBoxed[dynamicMember: \.[dynamicMember: \Foo.count]])
(edited)
Avatar
swift55 BOT 29-Dec-21 11:29 AM
0 0 0
stderr:
<stdin>:16:17: warning: cannot form key path that captures non-sendable type 'WritableKeyPath<Foo, Int>' print(boxedBoxed.count) ^ <stdin>:17:35: warning: cannot form key path that captures non-sendable type '(dynamicMember: WritableKeyPath<Foo, Int>)' print(boxedBoxed[dynamicMember: \.[dynamicMember: \Foo.count]]) ^
(edited)
Avatar
Iceman 29-Dec-21 11:59 AM
@swift-5.5.3 -warn-concurrency
struct Box { subscript<T>(bar bar: T) -> T { bar } } let _ = \Box[bar: 1] let _ = \Box[bar: \Int.description]
(edited)
Avatar Iceman
@swift-5.5.3 -warn-concurrency
struct Box { subscript<T>(bar bar: T) -> T { bar } } let _ = \Box[bar: 1] let _ = \Box[bar: \Int.description]
(edited)
Avatar
swift55 BOT 29-Dec-21 11:59 AM
stderr:
<stdin>:8:13: warning: cannot form key path that captures non-sendable type '(bar: KeyPath<Int, String>)' let _ = \Box[bar: \Int.description] ^
(edited)
Avatar
log5 30-Dec-21 01:47 PM
@swift-5.2.5
import Foundation let pi = 3.14159265359 print(String(format: "%f", pi))
(edited)
Avatar log5
@swift-5.2.5
import Foundation let pi = 3.14159265359 print(String(format: "%f", pi))
(edited)
Avatar
swift52 BOT 30-Dec-21 01:47 PM
3.141593
(edited)
Avatar
Iceman 02-Jan-22 09:16 AM
@swift-nightly -warn-concurrency
@_predatesConcurrency import Foundation func f<T: Sendable>(_: T) { } f(Date())
Avatar Iceman
@swift-nightly -warn-concurrency
@_predatesConcurrency import Foundation func f<T: Sendable>(_: T) { } f(Date())
Avatar
swiftNightly BOT 02-Jan-22 09:16 AM
no output
Avatar
norio_nomura 12-Jan-22 03:20 PM
@swift-5.6-dev -version
Avatar norio_nomura
@swift-5.6-dev -version
Avatar
swift56 BOT 12-Jan-22 03:20 PM
Swift version 5.6-dev (LLVM 64a4d678f114158, Swift 8ae983c3480462b) Target: x86_64-unknown-linux-gnu
Avatar
Iceman 17-Jan-22 09:30 AM
@swift-5.5.3 @swift-5.6-dev @swift-nightly
import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {}
(edited)
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev @swift-nightly
import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {}
(edited)
Avatar
swift55 BOT 17-Jan-22 09:30 AM
exit status: 134 with stderr:
swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.5-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2217: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.5.2-dev (LLVM c315411fac10439, Swift ef1fbfd974df3ad) 2. 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR for source file <stdin> 6. While emitting field type metadata 'S' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5c5ffb3] /usr/bin/swift-frontend[0x5c5dd0e] /usr/bin/swift-frontend[0x5c6033c] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f5109d5a980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f51085fcfb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f51085fe921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f51085ee48a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f51085ee502] /usr/bin/swift-frontend[0x181fed5] /usr/bin/swift-frontend[0x182c0f6] /usr/bin/swift-frontend[0x182903d] /usr/bin/swift-frontend[0x1827cf2] /usr/bin/swift-frontend[0x1826bde] /usr/bin/swift-frontend[0x1821b21] /usr/bin/swift-frontend[0xb239cd] /usr/bin/swift-frontend[0xb23bdf] /usr/bin/swift-frontend[0xacd38d] /usr/bin/swift-frontend[0xad1545] /usr/bin/swift-frontend[0xad4807] /usr/bin/swift-frontend[0xad4770] /usr/bin/swift-frontend[0x9ba13c] /usr/bin/swift-frontend[0xad436d] /usr/bin/swift-frontend[0xad416b] /usr
(edited)
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev @swift-nightly
import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {}
(edited)
Avatar
swift56 BOT 17-Jan-22 09:30 AM
exit status: 134 with stderr:
swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.6-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2254: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 64a4d678f114158, Swift 8ae983c3480462b) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR for source file <stdin> 6. While emitting field type metadata 'S' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa3093] /usr/bin/swift-frontend[0x5fa0c3e] /usr/bin/swift-frontend[0x5fa3426] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f2b4bf89980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f2b4a217fb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f2b4a219921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f2b4a20948a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f2b4a209502] /usr/bin/swift-frontend[0x18b1185] /usr/bin/swift-frontend[0x18be316] /usr/bin/swift-frontend[0x18bb174] /usr/bin/swift-frontend[0x18b9db9] /usr/bin/swift-frontend[0x18b851e] /usr/bin/swift-frontend[0x18b2f55] /usr/bin/swift-frontend[0xb2e7dd] /usr/bin/swift-frontend[0xb2ea51] /usr/bin/swift-frontend[0xad4fdf] /usr/bin/swift-frontend[0xad9045] /usr/bin/swift-frontend[0xadc317] /usr/bin/swift-frontend[0xadc280] /usr/bin/swift-frontend[0x9bf88c] /usr/bin/swift-frontend[0xadbe7d] /usr/bin/swift-frontend[0xadbc7b] /usr/bin/swift-frontend[0xad9205] /usr/bin/swift-frontend[0xad7f29] /usr/bin/swift-front
(edited)
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev @swift-nightly
import Foundation @propertyWrapper struct W<T>: Sendable where T: Sendable { var wrappedValue: T } struct S { @W var ok: Int @W var ng: Date } extension Date: @unchecked Sendable {}
(edited)
Avatar
swiftNightly BOT 17-Jan-22 09:31 AM
exit status: 134 with stderr:
swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2287: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 7b20e61dd04138a, Swift 9438cf6b2e83c5f) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR for source file <stdin> 6. While emitting field type metadata 'S' (at <stdin>:8:1) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x60543e3] /usr/bin/swift-frontend[0x6051f8e] /usr/bin/swift-frontend[0x6054776] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f7a34a14980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f7a32ca0fb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f7a32ca2921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f7a32c9248a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f7a32c92502] /usr/bin/swift-frontend[0x1951be5] /usr/bin/swift-frontend[0x195ef76] /usr/bin/swift-frontend[0x195bce2] /usr/bin/swift-frontend[0x195a909] /usr/bin/swift-frontend[0x195902e] /usr/bin/swift-frontend[0x19539b7] /usr/bin/swift-frontend[0x9cf0ad] /usr/bin/swift-frontend[0x9cf321] /usr/bin/swift-frontend[0x97563f] /usr/bin/swift-frontend[0x9796f1] /usr/bin/swift-frontend[0x97ca3c] /usr/bin/swift-frontend[0x97c990] /usr/bin/swift-frontend[0x85e4bc] /usr/bin/swift-frontend[0x97c58d] /usr/bin/swift-frontend[0x97c38b] /usr/bin/swift-frontend[0x9798f5] /usr/bin/swift-frontend[0x9785b9] /usr/bin/swift-frontend[
Avatar
kateinoigakukun 17-Jan-22 09:35 AM
コンパイラクラッシャー
Avatar
Iceman 17-Jan-22 09:35 AM
ww
Avatar
kateinoigakukun 17-Jan-22 09:36 AM
わからん。そしてmacOSで再現しないからFondation.Dateの定義が関係してそう
Avatar
Iceman 17-Jan-22 09:36 AM
そうなんですよ。macOSで再現しなくて、LinuxのCIで発覚しました
Avatar
kateinoigakukun 17-Jan-22 09:37 AM
デバッグお疲れさまです…
Avatar
Iceman 17-Jan-22 09:39 AM
5.5.1だといける
Avatar
kateinoigakukun 17-Jan-22 09:41 AM
SwiftFiddle is an online playground for creating, sharing and embedding Swift fiddles (little Swift programs that run directly in your browser).
これか。確かにテストケースにNSObjectのケースが無い https://github.com/apple/swift/pull/39782
Marker protocols don't exist at runtime, drop them when mangling a type for the purposes of runtime type metadata or reflection. Fixes rdar://82314404.
Avatar
Iceman 17-Jan-22 09:52 AM
NSObjectかどうかじゃなくて、外からimportした型にextensionでSendable つけてるかどうかな気がするんですよね
Avatar
kateinoigakukun 17-Jan-22 09:54 AM
レポートしたらシュッと直してくれないかな
Avatar
Iceman 17-Jan-22 11:09 AM
Avatar
Iceman 21-Jan-22 07:16 AM
@swift-5.5.3 @swift-5.6-dev -warn-concurrency
protocol Animal: Sendable { associatedtype ID: Sendable } protocol P { func f<A: Animal>(type: A.Type, id: A.ID) async } actor Foo: P { func f<A: Animal>(type: A.Type, id: A.ID) async {} } actor Bar { func f<A: Animal>(type: A.Type, id: A.ID) async {} }
(edited)
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev -warn-concurrency
protocol Animal: Sendable { associatedtype ID: Sendable } protocol P { func f<A: Animal>(type: A.Type, id: A.ID) async } actor Foo: P { func f<A: Animal>(type: A.Type, id: A.ID) async {} } actor Bar { func f<A: Animal>(type: A.Type, id: A.ID) async {} }
(edited)
Avatar
swift56 BOT 21-Jan-22 07:16 AM
no output
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev -warn-concurrency
protocol Animal: Sendable { associatedtype ID: Sendable } protocol P { func f<A: Animal>(type: A.Type, id: A.ID) async } actor Foo: P { func f<A: Animal>(type: A.Type, id: A.ID) async {} } actor Bar { func f<A: Animal>(type: A.Type, id: A.ID) async {} }
(edited)
Avatar
swift55 BOT 21-Jan-22 07:17 AM
stderr:
<stdin>:10:10: warning: cannot pass argument of non-sendable type 'A.ID' across actors func f<A: Animal>(type: A.Type, id: A.ID) async {} ^
Avatar
Iceman 21-Jan-22 07:17 AM
5.5.2のバグなのか
Avatar
log5 27-Jan-22 03:24 PM
@swift-5.4.3
// may cause "Cannot convert value of type 'Int' to expected argument type 'Builtin.FPIEEE64'" import Foundation let (N, M, K) = {() -> (Int, Int, Int) in let v = readLine()!.split(separator:" ").map{Int($0)!} return (v[0], v[1], v[2]) }() guard N - M >= K else { print(1.0) exit(0) } let b: [Double] = stride(from: N, through: N - K + 2, by: -1) .map({ i -> Double in Double(i)}) .map({ e -> Double in Double(e - 1 - M) / e }) let hazure = b.reduce(1.0) { (partialResult: inout Double, v: Double) -> Double in partialResult * v } let atari: Double = Double(M) / Double(N - K + 1) print(hazure * atari)
Avatar log5
@swift-5.4.3
// may cause "Cannot convert value of type 'Int' to expected argument type 'Builtin.FPIEEE64'" import Foundation let (N, M, K) = {() -> (Int, Int, Int) in let v = readLine()!.split(separator:" ").map{Int($0)!} return (v[0], v[1], v[2]) }() guard N - M >= K else { print(1.0) exit(0) } let b: [Double] = stride(from: N, through: N - K + 2, by: -1) .map({ i -> Double in Double(i)}) .map({ e -> Double in Double(e - 1 - M) / e }) let hazure = b.reduce(1.0) { (partialResult: inout Double, v: Double) -> Double in partialResult * v } let atari: Double = Double(M) / Double(N - K + 1) print(hazure * atari)
Avatar
swift54 BOT 27-Jan-22 03:24 PM
exit status: 1 with stderr:
<stdin>:15:10: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions .map({ e -> Double in Double(e - 1 - M) / e }) ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <stdin>:16:28: error: cannot convert value of type '(inout Double, Double) -> Double' to expected argument type '(Double, Double) throws -> Double' let hazure = b.reduce(1.0) { (partialResult: inout Double, v: Double) -> Double in partialResult * v } ^
Avatar
Iceman 31-Jan-22 03:35 AM
@swift-5.5.3 @swift-5.6-dev
import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil")
(edited)
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev
import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil")
(edited)
Avatar
swift56 BOT 31-Jan-22 03:35 AM
exit status: 134 with stderr:
swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.6-package-linux-ubuntu-18_04/swift/lib/AST/ASTMangler.cpp:2254: void swift::Mangle::ASTMangler::appendProtocolName(const swift::ProtocolDecl *, bool): Assertion `AllowMarkerProtocols || !protocol->isMarkerProtocol()' failed. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.6-dev (LLVM 64a4d678f114158, Swift 8ae983c3480462b) 2. Compiling with the current language version 3. While running user code "<stdin>" 4. While evaluating request IRGenRequest(IR Generation for module main) 5. While emitting IR SIL function "@$s4main1SV4_foo33_1A61A3E7348A44FC8FF8726B26BEB4EDLL_WZ". for declaration 0xb2c3c68 (in module 'main') Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /usr/bin/swift-frontend[0x5fa3093] /usr/bin/swift-frontend[0x5fa0c3e] /usr/bin/swift-frontend[0x5fa3426] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f378e08d980] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f378c31bfb7] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f378c31d921] /lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x7f378c30d48a] /lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x7f378c30d502] /usr/bin/swift-frontend[0x18b1185] /usr/bin/swift-frontend[0x18be316] /usr/bin/swift-frontend[0x18bb174] /usr/bin/swift-frontend[0x18b9db9] /usr/bin/swift-frontend[0x18b851e] /usr/bin/swift-frontend[0x18b2f55] /usr/bin/swift-frontend[0xb2e7dd] /usr/bin/swift-frontend[0xb2ea51] /usr/bin/swift-frontend[0xad4fdf] /usr/bin/swift-frontend[0x9b17e5] /usr/bin/swift-frontend[0x9b4ae4] /usr/bin/swift-frontend[0xb3bbf0] /usr/bin/swift-frontend[0xb3320b] /usr/bin/swift-frontend[0xb3034c] /usr/bin/swift-frontend[0xa2d3bb] /usr/bin/swift-frontend[0x95ad10] /usr/bin/swift-fro
(edited)
Avatar Iceman
@swift-5.5.3 @swift-5.6-dev
import Foundation struct S { @TaskLocal static var foo: Date? } extension Date: @unchecked Sendable {} print(S.foo ?? "nil")
(edited)
Avatar
swift55 BOT 31-Jan-22 03:35 AM
nil
(edited)
Avatar
Iceman 31-Jan-22 04:18 AM
あれ、実行時エラーじゃなくてコンパイラのクラッシュになった
5.5と5.6で挙動違うし、macとLinuxでも挙動違っててわけわからん
Linuxにおけるコンパイラのクラッシュは https://discord.com/channels/291054398077927425/430242233468452865/932567619192619040 と同じか? 5.5.2コンパイラがクラッシュしてないので微妙に違いそう (edited)
Avatar
omochimetaru 31-Jan-22 04:29 AM
5.5と5.6で挙動違うし、macとLinuxでも挙動違っててわけわからん
多彩なバグだな
Avatar
nanasi 02-Feb-22 02:34 AM
@swift-5.6-dev @swift-5.5.3
struct Links: Codable { let `self`: String init(self aSelf: String) { self.`self` = aSelf } }
(edited)
Avatar nanasi
@swift-5.6-dev @swift-5.5.3
struct Links: Codable { let `self`: String init(self aSelf: String) { self.`self` = aSelf } }
(edited)
Avatar
swift56 BOT 02-Feb-22 02:34 AM
stderr:
<unknown>:0: warning: 'self' refers to the method 'Links.CodingKeys.self', which may be unexpected <unknown>:0: note: use 'Links.CodingKeys.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning
(edited)
Avatar nanasi
@swift-5.6-dev @swift-5.5.3
struct Links: Codable { let `self`: String init(self aSelf: String) { self.`self` = aSelf } }
(edited)
Avatar
swift55 BOT 02-Feb-22 02:35 AM
no output
Avatar
nanasi 02-Feb-22 02:37 AM
@swift-5.6-dev @swift-5.5.3
struct Links: Codable { let `self`: String }
Avatar nanasi
@swift-5.6-dev @swift-5.5.3
struct Links: Codable { let `self`: String }
Avatar
swift55 BOT 02-Feb-22 02:37 AM
no output
Avatar nanasi
@swift-5.6-dev @swift-5.5.3
struct Links: Codable { let `self`: String }
Avatar
swift56 BOT 02-Feb-22 02:37 AM
stderr:
<unknown>:0: warning: 'self' refers to the method 'Links.CodingKeys.self', which may be unexpected <unknown>:0: note: use 'Links.CodingKeys.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning <unknown>:0: warning: 'self' refers to the method 'Links.self', which may be unexpected <unknown>:0: note: use 'Links.self' to silence this warning
Avatar
nanasi 08-Feb-22 03:23 AM
@swift-5.6-dev @swift-5.5.3
import Foundation @propertyWrapper struct Wrapper { var wrappedValue: Int? var projectedValue: String? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } init(projectedValue: String?) { self.projectedValue = projectedValue } } func foo(@Wrapper value: Int?) { print(value) } foo(value: 100) foo($value: "string")
Avatar nanasi
@swift-5.6-dev @swift-5.5.3
import Foundation @propertyWrapper struct Wrapper { var wrappedValue: Int? var projectedValue: String? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } init(projectedValue: String?) { self.projectedValue = projectedValue } } func foo(@Wrapper value: Int?) { print(value) } foo(value: 100) foo($value: "string")
Avatar
swift56 BOT 08-Feb-22 03:23 AM
Optional(100) nil
stderr:
<stdin>:18:9: warning: expression implicitly coerced from 'Int?' to 'Any' print(value) ^~~~~ <stdin>:18:9: note: provide a default value to avoid this warning print(value) ^~~~~ ?? <#default value#> <stdin>:18:9: note: force-unwrap the value to avoid this warning print(value) ^~~~~ ! <stdin>:18:9: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(value) ^~~~~ as Any
Avatar nanasi
@swift-5.6-dev @swift-5.5.3
import Foundation @propertyWrapper struct Wrapper { var wrappedValue: Int? var projectedValue: String? init(wrappedValue: Int?) { self.wrappedValue = wrappedValue } init(projectedValue: String?) { self.projectedValue = projectedValue } } func foo(@Wrapper value: Int?) { print(value) } foo(value: 100) foo($value: "string")
Avatar
swift55 BOT 08-Feb-22 03:23 AM
exit status: 1 with stderr:
<stdin>:21:1: error: type of expression is ambiguous without more context foo(value: 100) ^~~~~~~~~~~~~~~ <stdin>:18:9: warning: expression implicitly coerced from 'Int?' to 'Any' print(value) ^~~~~ <stdin>:18:9: note: provide a default value to avoid this warning print(value) ^~~~~ ?? <#default value#> <stdin>:18:9: note: force-unwrap the value to avoid this warning print(value) ^~~~~ ! <stdin>:18:9: note: explicitly cast to 'Any' with 'as Any' to silence this warning print(value) ^~~~~ as Any
Avatar
norio_nomura 12-Feb-22 07:04 AM
@swift-5.5.3 -version
Avatar norio_nomura
@swift-5.5.3 -version
Avatar
swift55 BOT 12-Feb-22 07:04 AM
Swift version 5.5.3 (swift-5.5.3-RELEASE) Target: x86_64-unknown-linux-gnu
👏🏻 1
Exported 4,301 message(s)